Skip to content Skip to sidebar Skip to footer

No Module Named Astropy

I've install the module Astropy for Python in mac using: pip install --user astropy It works when I installed but when I execute this code I have an error. import astropy astropy.

Solution 1:

With the Python executable you're using, try installing it as follows:

python -m pip install --user astropy

It is likely the pip you're using does not match the python you're using.

Solution 2:

Check your PYTHONPATH environment variable. After pip installation with --user option, astropy could be stored in a directory like ~/.local/lib/python3.6/site-packages/.

In bash you can do

export PYTHONPATH=$HOME/.local/lib/python3.6/site-packages/

You can include this line in the ~/.bashrc file.

Solution 3:

I faced this problem when I installed the updates for my "macOS Catalina". I'm using anaconda for python3. and I had to re-install it again. The problem is that some of the installation packages like ".matplotlip" or ".astropy" remain in the home directory (hidden) and when you load them instead of your anaconda path it goes to the location of these temporary files. I solved it by simply deleting them using

rm -r .matplotlib

and similar packages in my home directory. I was using astropy for the "LightKurv" package.

Post a Comment for "No Module Named Astropy"