没有名为 pandas 的模块

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

No module named pandas

pythonpandas

提问by Cachario

I am new to python and I am trying to make a simple stock market program using pandas to import the data. I have installed Anaconda which said that it installed pandas along with it, as well as Python 2.7. I use PyCharm as my IDE. When I run:

我是 python 的新手,我正在尝试使用 Pandas 来制作一个简单的股票市场程序来导入数据。我已经安装了 Anaconda,它说它安装了 Pandas,以及 Python 2.7。我使用 PyCharm 作为我的 IDE。当我运行时:

import pandas as pd

from pandas_datareader import data

I receive the error message

我收到错误消息

import pandas as pd

ImportError: No module named pandas

I am not sure why it is giving me this error message so any help would be greatly appreciated

我不知道为什么它给我这个错误信息所以任何帮助将不胜感激

回答by M. D. P

Try to install it using sudo...

尝试使用sudo安装它...

sudo pip3 install pandas

sudo pip3 install pandas

for ubuntu ... it worked got me. pip or pip3 .. as per your requirement.

对于 ubuntu ......它对我有用。pip 或 pip3 .. 根据您的要求。

回答by Wilfred Ruck

When entering the command to run your file, make sure you specify which version of python you're using. For example, instead of python filename.py, use python3 filename.pyor python2 filename.py

输入命令以运行文件时,请确保指定您使用的 Python 版本。例如,代替python filename.py,使用python3 filename.pypython2 filename.py

回答by hd1

You need to pip install pandasand things will work.

你需要pip install pandas,事情就会奏效。

回答by James

Your issue is that pandasis not installed locally on your computer. Luckily, this is a simple task to accomplish by opening up either a Terminal or Command Prompt (depending on your OS), and typing in the command pip install pandas. This will install pandas and you will be good to go!

您的问题是pandas未在您的计算机上本地安装。幸运的是,这是一项简单的任务,只需打开终端或命令提示符(取决于您的操作系统),然后输入命令pip install pandas. 这将安装Pandas,你会很高兴!

回答by Martin Liu

The issue is that Anaconda installs a Python version of its own, and likely the Python version is Python 3. When you use PyCharm IDE as your editor, you are using another version of Python (Python2). For my Mac, Anaconda's Python is installed under /anaconda3/binand my default Python is installed under /usr/bin/python.

问题是 Anaconda 安装了自己的 Python 版本,并且 Python 版本可能是 Python 3。当您使用 PyCharm IDE 作为编辑器时,您正在使用另一个版本的 Python (Python2)。对于我的 Mac,Anaconda 的 Python/anaconda3/bin安装在/usr/bin/python.

I recommend you either config PyCharm to use Anaconda's Python, or use Anaconda's Jupyter your project. Jupyter is arguably a stronger tool considering that you are doing data analytics task.

我建议您将 PyCharm 配置为使用 Anaconda 的 Python,或者在您的项目中使用 Anaconda 的 Jupyter。考虑到您正在执行数据分析任务,Jupyter 可以说是一个更强大的工具。

Also, for Anaconda's python, you shoud use conda install pandasinstead of pip install pandasto install additional packages. This is not necessary this time since it's already installed.

此外,对于 Anaconda 的 python,您应该使用conda install pandas而不是pip install pandas安装其他软件包。这次没有必要,因为它已经安装了。