问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

python需要设置哪些环境变量?我只知道一个PYTHONHOME指向安装目录。_百 ...

发布网友 发布时间:2022-04-22 22:11

我来回答

6个回答

热心网友 时间:2022-04-06 15:16

1、首先,右键点击-计算机(此电脑),点击进入属性,如图所示。

2、进入系统熟悉后,在点击进入-高级系统设置,如图所示。

3、在系统属性中,单击-环境变量-按钮,如图所示。

4、在环境变量页面中,点击“Administrator的用户变量”下面的-新建,如图所示。

5、在新建用户变量中,设置变量名:Path  变量值C:\Python\Python27;C:\Python\Python27\Scripts;如图所示版本不同手动更改,如:C:\Python\Python37;C:\Python\Python37\Scripts。

6、点击确定后,环境变量中即会出现新的用户变量,接着再次点击确定,即可设置完成,如图所示。

热心网友 时间:2022-04-06 16:34

1. 一般系统(Windows/Linux/....)Python被安装后解释器启动(例如python, python3 等命令)都可以自己找到"家"的, 不要设这个环境变量, 这个家就是解释本身附带的模块库或者将来安装其他的Python模块库的路径起始点.
如果你设了这个变量, 那么解释器的"家", 就被覆盖了, 然后不信你试试(保证PYTHONHOME设的目录存在), 设好这个环境变量以后, 然后运行如下命令: 1. python 基本马上提示:
ImportError: No mole named site 他找不到家了

2. PYTHONHOME 一般是自己在指定位置给python安了新家, 不同于系统安装的目录位置, 一般为了安装一个特定版本python发布, 而不伤害到系统本身的安装, 才设这个变量, 同样你如果要安装工作在这个版本上的其他Python程序同样要指定这个变量!

热心网友 时间:2022-04-06 18:09

就这个问题而言,需要将PYTHONHOME添加到环境变量。否则在Python与C++等混合编程的时候会遇到问题。当然,如果没添加的话,在代码中也可以用C++函数:Py_SetPythonHome来代替,但是后者是临时的,必须每次都设置。

热心网友 时间:2022-04-06 20:00

直接安装的不需要设置。

热心网友 时间:2022-04-06 22:08

正常来说应该是可以什么都不用设置的,比如说你说的PYTHONHOME,这个不是需要你设置来指定一个目录的,而是当你需要修改默认目录的时候才应该修改这个环境变量,具体可以参考官方文档:

PYTHONHOME
Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.

When PYTHONHOME is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.

PYTHONPATH
Augment the default search path for mole files. The format is the same as the shell’s PATH: one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent directories are silently ignored.

In addition to normal directories, indivial PYTHONPATH entries may refer to zipfiles containing pure Python moles (in either source or compiled form). Extension moles cannot be imported from zipfiles.

The default search path is installation dependent, but generally begins with prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to PYTHONPATH.

An additional directory will be inserted in the search path in front of PYTHONPATH as described above under Interface options. The search path can be manipulated from within a Python program as the variable sys.path.

PYTHONSTARTUP
If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same namespace where interactive commands are executed so that objects defined or imported in it can be used without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file.
PYTHONY2K
Set this to a non-empty string to cause the time mole to require dates specified as strings to include 4-digit years, otherwise 2-digit years are converted based on rules described in the time mole documentation.
PYTHONOPTIMIZE
If this is set to a non-empty string it is equivalent to specifying the -O option. If set to an integer, it is equivalent to specifying -O multiple times.
PYTHONDEBUG
If this is set to a non-empty string it is equivalent to specifying the -d option. If set to an integer, it is equivalent to specifying -d multiple times.
PYTHONINSPECT
If this is set to a non-empty string it is equivalent to specifying the -i option.

This variable can also be modified by Python code using os.environ to force inspect mode on program termination.

PYTHONUNBUFFERED
If this is set to a non-empty string it is equivalent to specifying the -u option.
PYTHONVERBOSE
If this is set to a non-empty string it is equivalent to specifying the -v option. If set to an integer, it is equivalent to specifying -v multiple times.
PYTHONCASEOK
If this is set, Python ignores case in import statements. This only works on Windows.
PYTHONDONTWRITEBYTECODE
If this is set, Python won’t try to write .pyc or .pyo files on the import of source moles.

New in version 2.6.

PYTHONIOENCODING
Overrides the encoding used for stdin/stdout/stderr, in the syntax encodingname:errorhandler. The :errorhandler part is optional and has the same meaning as in str.encode().

New in version 2.6.

PYTHONNOUSERSITE
If this is set, Python won’t add the user site-packages directory to sys.path.

New in version 2.6.

See also PEP 370 – Per user site-packages directory
PYTHONUSERBASE
Defines the user base directory, which is used to compute the path of the user site-packages directory and Distutils installation paths for python setup.py install --user.

New in version 2.6.

See also PEP 370 – Per user site-packages directory
PYTHONEXECUTABLE
If this environment variable is set, sys.argv[0] will be set to its value instead of the value got through the C runtime. Only works on Mac OS X.
PYTHONWARNINGS
This is equivalent to the -W option. If set to a comma separated string, it is equivalent to specifying -W multiple times.
1.2.1. Debug-mode variables
Setting these variables only has an effect in a debug build of Python, that is, if Python was configured with the --with-pydebug build option.

PYTHONTHREADDEBUG
If set, Python will print threading debug info.

Changed in version 2.6: Previously, this variable was called THREADDEBUG.

PYTHONDUMPREFS
If set, Python will mp objects and reference counts still alive after shutting down the interpreter.
PYTHONMALLOCSTATS
If set, Python will print memory allocation statistics every time a new object arena is created, and on shutdown.

热心网友 时间:2022-04-07 00:33

不配也能用~~
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
酸醋萝卜怎么做又脆又好吃 账簿启用及交接表填写的步骤 账簿启用及交接表怎样填写 说的是精神分裂症,吃了二年多的药,分别是利培酮片,苯海索片,补脑_百度... 精神分裂症急性期适当的治疗方法 快递三斤荔枝的话要多少钱? 求高手指点一个plc编程问题,计算时间差,还有时间比较后,输出执行... 你好高手 我现在买了个松下fp0的PLC我想写一个步进程序,请问能否... 【plc执行程序步骤】 plc执行程序时 若有一步不能满足条件而执行不了... 电脑屏幕的壁纸怎么更换? win7如何配置Python环境变量 如何配置python的环境变量? alp-al00是华为什么型号? photoshop中的如何改变背景图层的颜色? 如何用Photoshop将照片背景换色 photoshop7怎么把照片背景换色 PS怎么修改图片颜色及背景? 笔记本电脑突然出现了噼里啪啦的声音 笔记本电脑音响不能用发出啪啪声 笔记本电脑开久了会出现“啪、啪、啪···”的声音,该怎么办啊? 笔记本电脑有啪啪声 为什么我听见笔记本啪的响了一声(关机的时候) 为什么笔记本电脑显示屏打开左边有“啪”的一声? 为什么我的笔记本电脑一开机会有事会有啪的一声响,还有我的电脑为什么一开始运行很慢,后来就好了? 我的笔记本电脑开机的时候偶尔会有啪的一声响,咋回事? 笔记本电脑啪一声黑屏关机 笔记本电脑屏幕啪的一声扣下来,会对电脑造成影响吗 笔记本电脑啪一声后开不了机 笔记本正在使用,突然“啪”的一声电流声,直接关机。就像长按电源键几秒后电脑突然关机那种情况。 笔记本电脑用着突然啪一声像断电似的关机了,手动再开机还能进系统,过... 怎么设置环境变量pythonpath 去证券交易所开户要怎么做? 证券交易开户步骤 开股票账户流程是怎样的? 五谷饭是由那五谷组成的? 证券开户流程是什么 五谷饭指的是哪几种米啊 证券公司开户流程是什么? 五谷杂粮,五谷是哪五谷? 证券公司开户交易的问题 五谷饭是什么? 民间的五谷是指那五种粮食? 五谷是哪五种? 现在的五谷是指哪五种粮食啊? 五谷丰登中的五谷是指哪些食物?古人的日常食物是啥? 五谷杂粮都包括什么,包括大米吗? 五谷指的是哪五种粮食? 怎样做五谷米饭,比例是多少,要用到哪些五谷食材 淘宝开店之后怎么运营? 现在做淘宝网店怎样?还能赚钱吗?