pandas 如何为python3导入pandas?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51231755/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 05:47:03  来源:igfitidea点击:

How to import pandas for python3?

pythonpandaspython-3.5

提问by moluku

I have a python script that uses pandas library. But when I try to install pandas using:

我有一个使用 Pandas 库的 python 脚本。但是当我尝试使用以下方法安装Pandas时:

pip install pandas

It says:

它说:

Installing collected packages: pytz, six, python-dateutil, numpy, pandas
Successfully installed numpy-1.14.5 pandas-0.23.3 python-dateutil-2.7.3 pytz-2018.5 six-1.11.0
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command

When I try to run my script again, it tells again that no module named pandas.

当我尝试再次运行我的脚本时,它再次告诉我没有名为 Pandas 的模块。

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    import pandas as pd
ImportError: No module named 'pandas'

After using the suggestion, I tried again pip install pandas but i get an error

使用该建议后,我再次尝试 pip install pandas 但出现错误

Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name main

Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name main

回答by JMC

I suggest a workaround while someone points out a definitive solution for your dependency hell: use a virtual environment.

我建议一种解决方法,而有人为您的依赖地狱指出了一个明确的解决方案:使用虚拟环境。

Using miniconda, download your package, install it and:

使用 miniconda,下载您的软件包,安装它并:

conda create -n py37 anaconda python=3.7
source activate py37
pip install pandas