Unexpected paths on PYTHONPATH

Hello... I've got this config:

PyCharm 2017.3.4 (Professional Edition)
Build #PY-173.4674.37, built on March 6, 2018
JRE: 1.8.0_152-release-1024-b15 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6

I start PyCharm from a script, since there's no way to set PYTHONPATH from inside of PyCharm (at least not easily). The PYTHONPATH in the script looks something like:

['/Users/me/Work/repo3/editshare-storage',
 '/Users/me/Work/repo3/editshare-storage/modules',
 '/Users/me/Work/repo3/editshare-storage/modules/libacl',
 '/Users/me/Work/repo3/editshare-storage/scripts',
 '']

I don't (think) I change the path anywhere inside PyCharm. I've checked in Edit Configurations and Preferences->Build, Execution. and no PYTHONPATH definitions are there. Looking at Deployment->Console->Python Console, all fields are blank except for `Python interpreter`. Add content roots to PYTHONPATH is checked and add source roots to PYTHONPATH is unchecked.

When I open the python console to check the PYTHONPATH, I see the following (some systemsy paths removed for brevity);

 ['/Users/me/Work/repo2/editshare-storage/modules',
 '/Users/me/Work/repo2/editshare-storage/modules/libacl',
 '/Users/me/Work/repo2/editshare-storage/modules/ark/ui',
 '/Users/me/Work/repo2/editshare-storage/scripts',
 '/Users/me/Work/repo2/editshare-cluster',
 '/Users/me/Work/repo3/editshare-storage',
 '/Users/me/Work/repo3/editshare-storage/modules',
 '/Users/me/Work/repo3/editshare-storage/modules/libacl',
 '/Users/me/Work/repo3/editshare-storage/scripts',]

The mystery is: Where did the /repo2/ paths come from?

I do have several subdirectories (repo1, repo2, repo3) where I keep copies of respositories at different stages of development. So, somewhere, I do have a /repo2/ directory with parallel stuff to /repo3/, but I don't see how it gets on the PYTHONPATH of my current (/repo3/) PyCharm session. It's caused great confusion, because some symbols, according to PyCharm, are undefined because it's looking in the /repo2/ directories for stuff but should only be looking in /repo3/.

I just found half the answer... In the project pane, I see this:I notice that at the end are some of the items appear twice (modules, ui, libacl, etc). If I right click on them and choose "Copy Path", and look at the path, some of the duplicates are both in /repo2/ and /repo3/. So that kind of answers "why" this is happening, but...

  • I have no idea how I got into this situation
  • How can I remove these entries? The only option seems to be "Delete" but it looks like it would delete them off the disk (which would be bad).
  • I also just noticed this in one of my other projects on /repo3/... there are /repo2/ duplicates under "External Libraries"

 

Can someone help?

Thanks!

0
1 comment
Avatar
Permanently deleted user

I at least figured out how to remove the entries, in case anyone is interested...

  • Go to Preferences->Project->Project Interpreter
  • Click on the teeny-tiny gear to the right of the interpreter pull-down, and choose "Show all"
  • On the bottom of the "Project Interpreters" window, click the right-most icon "Choose paths for selected interpreter"
  • On the "Interpreter Paths" window you can then select items and click the "-" button at the bottom of the panel

Doing this marks the items "(removed by user)", but that's OK since they're effectively removed from the project.

0

Please sign in to leave a comment.