问题
I am using anaconda for this. I have downloaded pandas using both:
pip install pandas
and
conda install pandas
They successfully install, and doing the installation again shows that they are already installed. However, when writing this line alone
import pandas as pd
I get this error message:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7dd3504c366f> in <module>
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'
I have no idea what to do.
回答1:
Have you enabled the conda environment where pandas was installed? For example, if you created the env using conda env create -n myenv
, then running the following before installing the package should help:
conda activate myenv
Where is pandas installed? If using linux you could try to run
locate "pandas/__init__.py"
to find where you have some copy of pandas.
回答2:
You don't necesarilly need an environment for this.
The real deal with this problem is to know what pip
or conda
you are actually using and then on which python
will the stuff be installed.
You can open python and:
import sys
sys.path
Like this you can know where your python is. Go to that folder and you'll also find a pip
.
Then you have two options:
1) Set this path on your environments variables => you won't ever have the problem unless you try to do another python installation (then yes, use conda environment )
2) In you command prompt your/pip/path/pip install pandas
来源:https://stackoverflow.com/questions/60922383/pandas-module-not-found-even-though-its-installed