如何在Windows中添加到PYTHONPATH,以便找到我的模块/软件包? [英] How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
问题描述
我有一个目录,托管所有我的Django应用(C:\My_Projects
).我想将此目录添加到我的PYTHONPATH
中,以便直接调用应用程序.
I have a directory which hosts all of my Django apps (C:\My_Projects
). I want to add this directory to my PYTHONPATH
so I can call the apps directly.
我尝试从Windows GUI(My Computer > Properties > Advanced System Settings > Environment Variables
)将C:\My_Projects\;
添加到我的Windows Path
变量中.但是它仍然不读取coltrane模块并生成此错误:
I tried adding C:\My_Projects\;
to my Windows Path
variable from the Windows GUI (My Computer > Properties > Advanced System Settings > Environment Variables
). But it still doesn't read the coltrane module and generates this error:
错误:没有名为coltrane的模块
Error: No module named coltrane
推荐答案
您知道在Windows上对我非常有效的方法.
You know what has worked for me really well on windows.
My Computer > Properties > Advanced System Settings > Environment Variables >
只需将路径添加为C:\ Python27(或安装python的任何位置)
Just add the path as C:\Python27 (or wherever you installed python)
OR
然后在系统变量下创建一个名为PythonPath
的新变量.在这个变量中,我有C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path
Then under system variables I create a new Variable called PythonPath
. In this variable I have C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path
这是对我有用的最佳方法,我在所提供的任何文档中都找不到.
This is the best way that has worked for me which I hadn't found in any of the docs offered.
编辑:对于那些无法获得它的人, 请添加
For those who are not able to get it, Please add
C:\ Python27;
C:\Python27;
以及它.否则它将永远无效.
这篇关于如何在Windows中添加到PYTHONPATH,以便找到我的模块/软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!