默认情况下不应该相同吗?如果没有,有没有办法解决这个问题,以便使用相同的 PYTHONPATH?
问问题
1734 次
2 回答
1
这可能不是理想的解决方案,但它确实有效,并且由我的老板提供。
修改 pycharm 的 django_manage.py,在顶部插入以下代码,在所有现有代码之前。django_manage.py 可以在 [PyCharm 安装目录]/helpers/pycharm/django_manage.py 中找到。
import site
import sys
# Add the locations missing from PYTHONPATH when running a manage.py task here.
ALLDIRS = [
r'C:\git_repos\src\dev\common\py',
r'C:\git_repos\src\dev\main_website',
]
# Remember original sys.path.
prev_sys_path = list(sys.path)
# Add each new site-packages directory.
for directory in ALLDIRS:
site.addsitedir(directory)
# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
于 2011-03-02T21:13:21.167 回答
0
您是否在 Settings > Python Interpreter 中为您的项目选择了正确的 python 安装?
于 2011-03-02T20:45:50.630 回答