Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python failure to manually import module

I have a python script (test.py) that requests the following imports:

from MolKit import Read

The module must be installed via ADFR Suite which creates a separate directory for the module with the _init_.py file at the top. And, I have edited the ~/.bashrc to append:

export PYTHONPATH="${PYTHONPATH}:/home/ThoughtfulHistorian/ADFRsuite-1.0/ADFRsuite_x86_64Linux_1.0/CCSBpckgs/MolKit"

Before running source ~/.bashrc. Still, the script returns an import failure:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

File "test.py", line 2, in <module>
    from MolKit import Read
ModuleNotFoundError: No module named 'MolKit'

I am running Python 3.8.10 on Ubuntu 20.04.4 LTS.

>Solution :

It is the directory containing the package directory which needs to be on PYTHONPATH, not the package directory itself.

Instead of

export PYTHONPATH="${PYTHONPATH}:/home/ThoughtfulHistorian/ADFRsuite-1.0/ADFRsuite_x86_64Linux_1.0/CCSBpckgs/MolKit"

use

export PYTHONPATH="${PYTHONPATH}:/home/ThoughtfulHistorian/ADFRsuite-1.0/ADFRsuite_x86_64Linux_1.0/CCSBpckgs"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading