1

Shouldn't it be the same by default? If not, is there some way to fix this so that the same PYTHONPATH is used?

Julian A.
  • 10,928
  • 16
  • 67
  • 107

2 Answers2

1

This may not be the ideal solution, but it works, and comes courtesy of my boss.

Modify pycharm's django_manage.py, inserting the following code at the top, before all existing code. django_manage.py can be found at [PyCharm install directory]/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
Wogan
  • 70,277
  • 5
  • 35
  • 35
Julian A.
  • 10,928
  • 16
  • 67
  • 107
0

Did you select the right python install for your project in Settings > Python Interpreter?

adamJLev
  • 13,713
  • 11
  • 60
  • 65