pandas 为什么安装成功后无法导入pandas?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33839960/
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
why can't import pandas after installed successfully?
提问by coder_view
I have installed pandas with command 'pip3.4 install pandas'.
我已经使用命令“pip3.4 install pandas”安装了Pandas。
Successfully installed pandas python-dateutil pytz numpy six
Cleaning up...
root@hwy:~# python3.4
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
Why can't import pandas in python3.4 after pandas been installed successfully?
python3.4中pandas安装成功后为什么不能导入pandas?
root@hwy:/home/debian8# pip3.4 show pandas
---
Name: pandas
Version: 0.17.1
Location: /usr/local/python3.4/lib/python3.4/site-packages
Requires: python-dateutil, pytz, numpy
root@hwy:/home/debian8# echo "import sys; print sys.path"
import sys; print sys.path
root@hwy:/home/debian8# python3.4
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages']
采纳答案by Mike Müller
Your pandas
is installed here:
你pandas
安装在这里:
/usr/local/python3.4/lib/python3.4/site-packages
But this path is not in sys.path
.
但是这条路不在sys.path
.
As a workaround do:
作为一种解决方法:
export PYTHONPATH=$PYTHONPATH:/usr/local/python3.4/lib/python3.4/site-packages
and inside this terminal start Python again and do your import of pandas
.
并在此终端内再次启动 Python 并导入pandas
.
If this works, add this line above (export PYTHONPATH...
) to your ~/.bashrc
or equivalent if you use a different shell for a more permanent solution.
如果可行,如果您使用不同的 shell 以获得更持久的解决方案,请将上面 ( export PYTHONPATH...
)行添加到您的~/.bashrc
或等效的行中。