导入错误:没有使用 Ubuntu 的名为“pandas”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44015941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named 'pandas' Using Ubuntu
提问by Ashish Odich
$ pip3 install pandas
Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2 in /usr/local/lib/python3.4/dist-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /usr/local/lib/python3.4/dist-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /usr/local/lib/python3.4/dist-packages (from pandas)
I am getting Import error while my system has already satisfied all requirements.
我的系统已满足所有要求时出现导入错误。
采纳答案by Guillaume Jacquenot
To be sure you are not having multiple Python versions that are confusing, you should run these commands
为确保您没有多个令人困惑的 Python 版本,您应该运行这些命令
python -m pip install pandas
python -c 'import pandas'
It installs pandas
and imports it with the same python version.
它pandas
使用相同的 python 版本安装和导入它。
Of course, you have to update the python
program in the above commands, in case it is not directly python
.
当然,你必须更新python
上面命令中的程序,如果不是直接更新python
。
If you have a python3
executable, you can try
如果你有一个python3
可执行文件,你可以试试
python3 -m pip install pandas
python3 -c 'import pandas'
You can even use absolute path, that would be returned by which python
, which python2
or which python3
, ...
您甚至可以使用绝对路径,该路径将由which python
,which python2
或which python3
, ...
回答by abccd
I believe you have multiple python3's. If everything else suggested doesn't work for you, a easy/hacky way is to do this before you import pandas, it will guarantee the usage of the correct interpreter. Do this just once, after its successfully installed, you no longer need to do that:
我相信你有多个 python3。如果建议的所有其他内容都不适合您,一个简单/hacky 的方法是在导入Pandas之前执行此操作,它将保证使用正确的解释器。只需执行一次,成功安装后,您不再需要这样做:
import pip
pip.main(['install','pandas'])
import pandas