我正在安装事件的 python、django。我不知道如何在vista环境系统中设置python路径。
首先它能在 Vista 中运行吗?
最佳答案
临时更改
要临时更改 python 路径(即,对于一个交互式 session ),只需附加到 sys.path
像这样:
>>> import sys
>>> sys.path
['',
'C:\\Program Files\\PyScripter\\Lib\\rpyc.zip',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
>>> sys.path.append(directory_to_be_added)
永久(或多或少)的变化
转到Computer -> System Properties (Either by the big button near the title bar or in the context-menu by right-clicking) -> Advanced Settings (in the right-hand nav bar) -> Environment Variables
。在 System Variables
,或者添加一个名为 PYTHONPATH
的变量(如果它还不存在,即,如果您之前没有这样做过)或编辑现有变量。
您应该正常输入目录(注意使用反斜杠,而不是普通的),并用分号( ;
)分隔,不带空格。请注意不要以分号结尾。
您刚刚输入的目录将添加到 sys.path
每当您打开解释器时,他们都不会替换它。此外,只有在您重新启动解释器后,更改才会发生。
来源:http://greeennotebook.com/2010/06/how-to-change-pythonpath-in-windows-and-ubuntu/
关于python - 如何在 Windows Vista 上设置 Python 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/450290/