Python 导入错误:没有名为 Pandas 的模块。Pandas 安装了 pip

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

ImportError: No module named pandas. Pandas installed pip

pythonmacospandas

提问by andy

i use mac terminal to check my package:

我使用 mac 终端来检查我的包裹:

pip list

i can find all packages include pandas

我可以找到所有包都包括熊猫

but when i

但是当我

import pandas

it told me:

它告诉我:

ModuleNotFoundError: No module named 'pandas'

ModuleNotFoundError: 没有名为“pandas”的模块

by the way, i have python2 and python3 in my mac, they are not the same directory,i suspect python didn't find the path of pandas

顺便说一句,我的mac中有python2和python3,它们不是同一个目录,我怀疑python没有找到pandas的路径

回答by Ahmed Ginani

First of all, install virtualenvinside your project folder to secure your project directory to avoid conflict with your other packages.

首先,安装virtualenv在您的项目文件夹中以保护您的项目目录,以避免与其他软件包发生冲突。

pip install virtualenv

After installing this run this command one by one inside your root project directory:

安装完这个后,在你的项目根目录中一一运行这个命令:

virtualenv venv
source venv/bin/activate

Now Your directory is secure and you can install your required packages inside.

现在你的目录是安全的,你可以在里面安装你需要的包。

pip install pandas

and others as you required.

和其他你需要的。

Because you have installed virtualenvand running as secure it will not conflict with other outside packages.

因为您已经virtualenv安全地安装和运行,所以它不会与其他外部软件包发生冲突。

Use this all steps one by one. I hope it will work for you to avoid such error.

一步一步地使用所有步骤。我希望它对您有用,可以避免此类错误。

Thanks.

谢谢。

回答by Pedro Rio

Try to install pandas using pip and pip3.

尝试使用 pip 和 pip3 安装 pandas。

pip install pandas

pip3 install pandas

A suggestion, use pyenv and set a python version for your local directory.

一个建议,使用 pyenv 并为您的本地目录设置一个 python 版本。

回答by solanki...

If python v2.7 is already installed, then to install numpy and pandas for v2.7. Run the below commands :

如果已经安装了 python v2.7,则为 v2.7 安装 numpy 和 pandas。运行以下命令:

for Ubuntu / Linux -

对于 Ubuntu / Linux -

sudo apt-get install python-numpy
sudo apt-get install python-pandas

If python v3 is already installed, then to install numpy and pandas for v3. Run the below commands :

如果已经安装了 python v3,则为 v3 安装 numpy 和 pandas。运行以下命令:

for Ubuntu / Linux -

对于 Ubuntu / Linux -

sudo apt-get install python3-numpy
sudo apt-get install python3-pandas

回答by v_kumar

I had Python2and Python3installed in different directories but I was facing this error because whenI was using the command pip install pandasit was installing pandas in Python2directories while I was using Python3

我已经Python2Python3安装在不同的目录中,但是我遇到了这个错误,因为当我使用该命令时,pip install pandas它正在Python2目录中安装pandas,而我正在使用Python3

So I had two diectories with Python2 --> C:\Python27and Python365 --> C:\Python365.

所以我有两个带有Python2 --> C:\Python27和的字典Python365 --> C:\Python365

To resolve this error:

要解决此错误:

Run pip install pandasin cmd. If library pandasis already installed you'll see something like following.

运行pip install pandascmd。如果库pandas已安装,您将看到如下内容。

C:\Users\vichitrak>pip install pandas
Requirement already satisfied: pandas in c:\python27\lib\site-packages (0.23.4)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\python27\lib\site-packages (from pandas) (2.7.3)
Requirement already satisfied: numpy>=1.9.0 in c:\python27\lib\site-packages (from pandas) (1.14.4)
Requirement already satisfied: pytz>=2011k in c:\python27\lib\site-packages (from pandas) (2018.4)
Requirement already satisfied: six>=1.5 in c:\python27\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)

From the output of above command you can see that pandasis installed in Python2directory i.e. c:\python27\lib\site-packages (0.23.4)

从上面命令的输出中你可以看到它pandas安装在Python2目录 iec:\python27\lib\site-packages (0.23.4)

Run pythoncommand in cmdto check which Pythonversion are you running.

运行python命令cmd以检查Python您正在运行的版本。

C:\Users\vichitrak>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information. 

You can see that I'm using Python3while pandasis installed in Python2directory`

您可以看到我正在使用Python3whilepandas安装在Python2目录中`

To install the pandasand other libraries in Python3go to scripts folderin Python3 directory i.e. C:\Python365\Scripts
Open Command Windowand run pip install pandas

要安装pandas在和其他图书馆Python3转到scripts folderPython3 directory i.e. C:\Python365\Scripts
打开Command Window和运行pip install pandas

Or you can use the complete path of pip in Python3 directoryon cmdto run the intsallcommand i.e. C:\Users\vichitrak>C:\Python365\Scripts\pip install pandas

或者你可以使用complete path of pip in Python3 directoryoncmd来运行intsall命令即C:\Users\vichitrak>C:\Python365\Scripts\pip install pandas

回答by Busybee sat

Sometimes, it might be due to an issue with "Microsoft visual C++".

有时,这可能是由于“Microsoft Visual C++”的问题。

  1. For that, first you need to install the "Microsoft visual C++" using the instructions given in the link: "[Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)"
  2. After successful installation, use pip install pandasto install pandas
  3. If pipis not installed, then download thr pandas source package with extension tar.gzand place it in directory wherever you want after extracting. open cmd.exeand navigate to the path where pandas folder is extracted & placed using cd C:/pandas. Then install it using the python setup.py install
  1. 为此,首先您需要使用链接中给出的说明安装“Microsoft Visual C++”:“[需要Microsoft Visual C++ 14.0(无法找到 vcvarsall.bat)
  2. 安装成功后,使用pip install pandas安装pandas
  3. 如果pip未安装,则下载带有扩展名的 thr pandas 源包,tar.gz并在解压缩后将其放在您想要的目录中。打开cmd.exe并导航到使用 .pandas 文件夹提取和放置的路径cd C:/pandas。然后使用安装python setup.py install

Finally you should get the success message as Finished processing dependencies for pandas==0.xx.0

最后你应该得到成功消息 Finished processing dependencies for pandas==0.xx.0