Python displays ‘library not loaded’

Python displays ‘library not loaded’ … here is a solution to the problem.

Python displays ‘library not loaded’

I’m trying to simply install a new module. But it keeps giving me errors. I have both python27 and python36 on my Mac. I was using python27 when this happened. I can’t run pip or conda.

After running:
pip installation area

I’m getting these errors :

dyld: Library not loaded: @rpath/libpython3.6m.dylib
Referenced from: /Users/yan/anaconda/bin/python
Reason: no suitable image found.  Did find:
/Users/yan/anaconda/bin/.. /lib/libpython3.6m.dylib: file too short
Abort trap: 6

Another related question, if I have some modules installed while using python36, can I import those modules in python27? Do I need to reinstall those? Thank you !!!

Solution

Unfortunately, not all modules are compatible with Anaconda Python (I saw from the logs that you use it). Such questions also arise
Virtual environment. But the regions document shows that the way to Install it with conda.

Using conda To install regions with Anaconda from the astropy channel
on anaconda.org simply run:

conda install -c astropy regions

On the second question – no, modules should be installed separately for Python 2 and 3

Related Problems and Solutions