PyCharm 2016.1.3 (and later) breaks loading custom modules sitting in the %PYTHONPATH% directory
With PyCharm 2016.1.2 and earlier, we could load our custom modules that are in deployed in our PYTHONPATH directory. With versions 2016.1.3 and later, we can’t. And hoping someone can offer advise for a settings workaround, but if not I will open a bug report.
We are running PyCharm 2016.1.2 in a Windows 7 environment, with Python 2.7.11 installed as our default interpreter.
Here is our directory structure:
%PYTHONPATH%/module1
%PYTHONPATH%/module1/__init__.py
%PYTHONPATH%/module1/_mydll1.pyd
%PYTHONPATH%/module1/custom1.py
Contents of module1/__init__.py is blank.
Contents of module1/custom1.py is just “from _mydll import *”
This works great 2016.1.2 and 2016.2.2:
- from module1 import _mydll
This used to work in 2016.1.2 and earlier, but now fails:
- from module1 import custom1 as c
If I explicitly add the %PYTHONPATH%/module1 path to my interpreter, then this works:
- from module1 import custom1 as c
Here is some some more directory structure for other likely related issues:
%PYTHONPATH%/module2
%PYTHONPATH%/module2/__init__.py
%PYTHONPATH%/module2/custom2.py
%PYTHONPATH%/module2/dir3
%PYTHONPATH%/module2/dir3/__init__.py
%PYTHONPATH%/module2/dir3/custom3.py
%PYTHONPATH%/module2/dir4
%PYTHONPATH%/module2/dir4/__init__.py
%PYTHONPATH%/module2/dir4/custom4.py
%PYTHONPATH%/module2/dir4/dir5
%PYTHONPATH%/module2/dir4/dir5/__init__.py
%PYTHONPATH%/module2/dir4/dir5/custom5.py
In these cases, the below commands in PyCharm 2016.1.2 work and fail for version >= 2016.1.3.
- from module2 import custom2
- from module2.dir3 import custom3
- from module2.dir4 import custom4
- from module2.dir4.dir5 import custom5 as c5
In all cases, If I explicitly add the custom module2 directory to the path of my interpreter, then I can load modules2, Sadly that does not work for directories nested under module2.
Again things “just work” with version 2016.1.2 without any settings voodoo. With version 2016.1.3 and higher whether upgrading my existing older install, invalidating the new caches and restarting, or just doing a fresh install --- skeletons do not get properly built. If I do a refresh install of 2016.1.2, they do.
We have been using PyCharm for quite a few years ---since the early beta days --- and this bug/behavior reminds of some of the Python path challenges from versions <= 2.0.
Any suggestions that do not involve adding each module individually to the path setting of my Python interpreter would be appreciated.
Cheers,
Rob
Please sign in to leave a comment.
Two more things. Running and script or app from the command line or PyCharm's Run\run command works great. The issue is skeletons and pathing for debug runs.
I also see that see that PyCharm 2016.2.3 was just released. Later this week I will try see how that new version works or doesn't and then reply back with my findings.
Handn't seen any feedback, so submitted a PyCharm bug: https://youtrack.jetbrains.com/issue/PY-20919