Ratha
Ratha

Reputation: 9702

Python gives ImportError: No module named sqlalchemy.util._collections in pycharm

I have installed sqlalchemy in my pathon. Im running python 2.7.15 When I execute my test program it says;

ImportError: No module named sqlalchemy.util._collections

I have installed modules with my python version.

WHy do I get this error in pycharm. PyCharm run configurations picks correct python version. In console i tried the import statement it works.

$ python --version
Python 2.7.15
>>> from sqlalchemy.util import _collections
>>> 

Why I get this error in pycharm?

Upvotes: 0

Views: 1241

Answers (2)

Ratha
Ratha

Reputation: 9702

This is due to Pywren [1] library which could not import some 3 rd party libraries. Not a Python/PyCharm issue

[1]https://github.com/pywren

[2]https://github.com/pywren/pywren/issues/253

Upvotes: 0

ScottMcC
ScottMcC

Reputation: 4460

First thing I would check is that you're using the correct Python environment in PyCharm.

Use the which python function in your console to see the path to the python executing in your terminal and make sure that it lines up with the path under "External Libraries" in your project view. You may not have sqlalchemy installed on the Python executable in your Pycharm Project. I've had similar issues in the past where I had Python installed alongside Anaconda.

Also consider dropping a requirements.txt file into the root level of your project in Pycharm. If your Python environment doesn't have the library installed it will generally prompt you to install it. Just add in a single line into your requirements.txt file with sqlalchemy. Using echo you could create this file using the following command

echo "sqlalchemy" >> requirements.txt

Upvotes: 1

Related Questions