How to add to the PYTHONPATH in Windows, so it finds my modules/packages?(如何添加到 Windows 中的 PYTHONPATH,以便找到我的模块/包?)
问题描述
我有一个存放我所有 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.
我尝试将 C:My_Projects; 从 Windows GUI 添加到我的 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.
我的电脑 >属性>高级系统设置 >环境变量>
只需将路径添加为 C:Python27(或安装 python 的任何位置)
Just add the path as C:Python27 (or wherever you installed python)
或
然后在系统变量下创建一个名为 PythonPath 的新变量.在这个变量中,我有 C:Python27Lib;C:Python27DLLs;C:Python27Liblib-tk;C:other-folders-on-the-path
Then under system variables I create a new Variable called PythonPath. In this variable I have C:Python27Lib;C:Python27DLLs;C:Python27Liblib-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,以便找到我的模块/包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何添加到 Windows 中的 PYTHONPATH,以便找到我的模块/包?
基础教程推荐
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 包装空间模型 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
