python - 如何在 Windows Vista 上设置 Python 路径?

标签 python windows-vista

我正在安装事件的 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/

相关文章:

python - 枚举数据加载器时出现 KeyError - 为什么?

python - QFileDialog 查看文件夹和文件但仅选择文件夹?

flash - 如何以编程方式防止 Vista(和 Windows 7)中的 "Program Compatibility Assistant"出现?

C++:在 Vista 上获取网络适配器的 MAC 地址?

delphi - 在Delphi中控制应用程序音量

python - 在 Python timedelta 对象上重新采样 Pandas 时间序列数据时出现问题

python - 我在哪里可以获得 delphi 或 python 的免费 G​​SM 库/组件?

python - 一维数组转换 : Distributing groups of different sizes into unique batches with certain conditions

winforms - 如何使用 Windows 窗体在窗口标题栏中绘制自定义按钮?

logging - C#中的事件记录器是否需要管理员权限才能将日志写入Windows Event Viewer?