Pandas Module Not Found even though it's installed

南楼画角 提交于 2021-01-28 20:26:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!