Even numpy can't be imported.
Confirmation when it is included in pip list
, but ...
When you have to build an environment on a messy machine.
First from here.
ls -l `which python3`
You can see where you are referring to when you type the command python3
.
Since there may be multiple pythons unintentionally included,
Make sure it matches what you want to use.
pip3 --version
ls -l `which pip3`
pip3 show [Module name]
For example, in the case of numpy
pip3 show numpy
If installed, pay attention to Location.
Name: numpy
Version: 1.18.1
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /usr/local/lib/python3.7/site-packages
python3
Enter to enter python3. Then execute the following 3 lines
import sys
import pprint
pprint.pprint(sys.path)
When the path is displayed, press control + D to exit. Check if the location of the module is here.
If not, check the environment variable PYTHONPATH
PYTHONPATH
echo $PYTHONPATH
If you write the location setting of the module here It works for the time being.
If bash
,
export PYTHONPATH=[Module Location]
If csh
,
setenv PYTHONPATH [Module Location]
Then, put it in the environment variable. Check with ʻecho $ PYTHONPATH`.
However, restarting the terminal resets the environment variables.
If you want to make it permanent, add it to bash_profile
or cshrc
.
(Please check the environment variable settings separately)
python3
import [Module name]
I will try.
Recommended Posts