ImportError of a module PyCharm otherwise finds


I have a problem importing a package - import bibeduce -> ImportError: No module named bibeduce. This works normaly outside PyCharm.
Same thing happens with other packages in that directory.

Thing is, package's directory is in PYTHONPATH, is found under "project interpreter", is autocompletable, and ctrl-clicking it will take me to the import, but run raises an ImportError which confuses and angers me.

I would be very apprecitive of any advice, since I have no idea how approach this problem.


Some additional info that might be relevant (sorry, was a bit hasty while writing the first message): running PyCharm 1.2.1 on Win 7, the problematic package is not part of same project and, indeed, is not a PyCharm project at all. I have been using the package in Python scripts on same system for some time now without any problems. However, same scripts raise error in PyCharm as described above.


Standard python run with default settings. Uses project default interpreter.


I'm guessing in your run config you have the same interpreter for runtime that you have attached to what PyCharm sees for autocomplete, etc? And that the proper working dir are set and everything?

I'm curious about your error. It sounds as though things are set up properly, unless windows 7 is doing something differently when it runs and altering your path, or your PYTHONPATH.

You're not using cygwin python libs right? You're on the win32 python build?


ceposta wrote:

I'm guessing in your run config you have the same interpreter for runtime that you have attached to what PyCharm sees for autocomplete, etc?


You're not using cygwin python libs right? You're on the win32 python build?

Yes, I'm using standard win32 python 2.71 installation. It is also the only python interpreter on the system, so no interpreter mismach should be possible i.e. It's either set or it isn't, i guess. While the project python interpreter normally lists the dir of the package I'm trying to import, it doesn't seem to be passed to the run, as printing sys.path before the import shows it does not contain the dirs on PYTHONPATH.

ceposta wrote:

And that the proper working dir are set and everything?

Working dir is left defaulting to the directory the script is in, which is also where I want it to be as some other assets are in the same dir.

Having to finish some work ASAP, I gave this up to gremlins, and temporarily (I hope) solved it by adding the directory that should be found from PYTHONPATH (and is   found for purposes of autocomplete, etc ... in fact, it is found by anything that is not a PyCharm run or debug, including other IDEs) to the project itself as additional content root. However, this is a bit annoying as it clutters many small projects I have. I work on data a lot and usually have one project per dataset I'm working on, making me want to fiddle as little as possible when setting up a new project.


Some questions:

  1. When you start a python interpreter from the command prompt and try to import it, what happens?
  2. Is it installed in Lib\site-packages or somewhere completely different?
  3. Have you tried removing PYTHONPATH (temporarily) from the environment variables (Python 2.7.x sets it by default on Windows nowadays) and then seeing if it auto-resolves correctly?

Hey, thanks for the interest guys!

To answer the questions:

1. As I said, anything that is not pyCharm (standard python command prompt, ipython, wing ide ...) has no problems with importing the package

2. It is somewhere completely different on the same system, ("d:\workbench\pyextend", where I want it to be for various reasons), but the dir is on PYTHONPATH, an is seen normaly by rest of the system

3. No, but, as explained in 2, the PYTHONPATH environment variable is the only thing making the package findeable?

BTW the package is my own framework for exploratory data preparation and analysis (pure python) and some of it's higher level derivatives (e.g. implementing data specific logic), and as such I use it for many a project. (I might release it if I ever have the time to wrap it up properly.) Point is, the system has been up and running for a few months now, the package has been used often in different projects by a few different python consoles/ides without problems. However, only pyCharm gives me trouble with it which I find rather annoying since it's the only IDE i bought and indeed, after testing most other python IDEs, currently my IDE of choice :-(

PS I posted this here simply hoping I just missed some pyCharm specific ways of handling external packages ... but I don't see why run would use different path than one listed under "project settings:python interpreter" if run config says "interpreter:project default".


Hi, I was facing the same problem with openpyxl.

I am using Python 3.5.3, openpyxl 2.4.1, and Pycharm CE 2016.3.2.

It worked with standard command line REPL, with Pycharm console, Pycharm editor autocomplete etc.

It didn't work only with Pycharm run or debug on a specific project.

It worked with other projects too.

In my case, the problem was related to namespace.

I had created a module called "" with a class Site. When I removed it, it worked fine. It only affects PyCharm, for some reason.


Gustavo Albuquerque can you please explain this in more detail.

I have the same problem with pyOpenSSL.  Works everywhere but PyCharm.  It cannot find the module.

I may try the hack to add its direct path to the lib path.  But I would like to understand WHY its not working as it should and as it does under all other methods of running my app..

Your cause/fix unfortunately does not help me.  I don;t understand how that can cause/fix the issue.  Or if I have a similar problem, how I can track it down,






Hi James, in my case it was a namespace conflict.

I believe the name "Site" was taken by openpyxl and the solution was to remove the module with the conflicting namespace.

You can try using dir() on pycharm to check the allocated names and look for potential collisions.




Its not a namespace conflict.  It appear to be that..

I upgraded to a new virtualenv 3.5 over 3.4..   with same requirements..  

Anyway, the "Run Configurations" did not also jump to the new version.  So I added pyopenssl to the project selected virtualenv..  but when I was running it, it was using the OLD one.  so it could not find the newly added pyopenssl.  Doh!  I must have been jumping around to other virtenvs before the upgrade and forgot to set it back to defaulting to the same as the project..





Please sign in to leave a comment.