Reputation: 87
I'm using robotframework for automation. I'm trying to use a method from my python library which needs psutil. The problem is when I execute from the robotframwork it gives error ImportError: No module named psutil
but when I execute it with Pycharm I don't get any error. I have installed psutil using pip install psutil
. I searched a lot on web but couldn't find any reason for this issue.
Upvotes: 2
Views: 12793
Reputation: 31
My experience with this error was that I had multiple versions of python installed on my ubuntu server 16.04LTS.
My PATH resolved to /usr/local/python
-> python 2.7.10 meaning typing python into the commandline I got 2.7.10, but the standard path /usr/bin/python
linked to python 2.7.12. The psutil module and others were only installed for version 2.7.10
My resolution was to re-symlink /usr/bin/python
to point to my 2.7.10 version:
# Find which python your PATH is pointing at and the version
$ which python
# Returns
/usr/local/bin/python
$ /usr/local/bin/python --version
# Returns
Python 2.7.10
$ /usr/bin/python --version
# Returns
Python 2.7.12
Unlink and relink to correct python version in /usr/bin/python
$ cd /usr/bin
$ sudo unlink python
$ sudo ln -s /usr/local/bin/python python
# check python version points correctly
$ /usr/bin/python --version
# Now correctly returns
Python 2.7.10
P.s. Bear in mind it's still worth checking all your modules are correctly installed now that your environment is pointing at the 1 python version
Upvotes: 2
Reputation: 101
Could you try setting the PYTHONPATH in your environment or by passing it as an option.
This person had a different issue, but the fix I think will be the same:
setup pythonpath before starting test suite
Cheers,
K
Upvotes: 1