PyCharm won't recognize installed module

已回答

PyCharm can't find a module that is listed in the project interpreter for the virtual environment the project is assigned to. Redis is obviously installed but I keep getting ModuleNotFoundError at runtime. The run configuration specifies the correct (project default) interpreter. The working directory and environment variables are correct. If I source the environment from the terminal it is able to import the package but the PyCharm python console can't.

I'm running PyCharm 2017.1.4 on a Mac running macOS 10.12.5. I've read the post at https://intellij-support.jetbrains.com/hc/en-us/community/posts/205804439-ImportError-of-a-module-PyCharm-otherwise-finds but this shouldn't be a PYTHONPATH problem.

If anyone has any advice, I'd appreciate it! Thanks.

2
Avatar
Permanently deleted user

I've also deleted and recreated the conda environment and it hasn't helped. I was able to use this package several months ago when I last worked on this project.

0

Hi akoue2001! Do you have any directories in you project marked as Source Root? Also are there any custom modules named redis in your project? Could you please try a virtualenv with a name not starting with a digit?

0
Avatar
Permanently deleted user

Solved! The error had to do with the fact that there are two redis modules available: redis and redis-py. If you look at the screenshot above, the version of redis that PyCharm installed (3.2.0) is higher than the version that PyCharm has marked as "latest" (2.10.5). I installed redis-py 2.10.5 (the only versions of redis available are 3.2.0 and 2.6.9), which installed redis-py 2.10.5 and redis 2.10.5. 

Process: I took your advice and created a new conda environment with all letters in the name. PyCharm generated a list of required packages (not including redis) and installed them. I hovered over the lightbulb icon and it asked me if I wanted to install redis and I clicked yes, so PyCharm installed the module (3.2.0). But even after confirming that the package was listed in the project interpreter settings, PyCharm still wasn't recognizing the module so I figured it might have been the discrepant versions, tracked down the 2.10.5 version, and installed it. Still don't understand why PyCharm downloads a module it can't recognize, but at least it runs.

Thanks for your help!

 

0

Thank you for investigation! I suspect conda installs redis server when you invoke:

conda install redis

and redis Python client when

conda install redis-py

so there is a confusion and PyCharm wrongly installs a server instead of a client.

I created a separate issue for the problem in our tracker, please follow: PY-24874.

0
Avatar
Permanently deleted user

Solved. I am now able to use the installed package. Please follow the step in this video: https://www.youtube.com/watch?v=RvbUqf3Tb1s.

0

Hello I am having a similar issue but for the life of me cannot figure it out. Any help would allow me to continue working. 

 

 

 

I don't understand what is going on? 

 

0

请先登录再写评论。