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
ImportError: No module named pandas. Pandas installed pip
提问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 virtualenv
inside 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 virtualenv
and 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 Python2
and Python3
installed in different directories but I was facing this error because whenI was using the command pip install pandas
it was installing pandas in Python2
directories while I was using Python3
我已经Python2
并Python3
安装在不同的目录中,但是我遇到了这个错误,因为当我使用该命令时,pip install pandas
它正在Python2
目录中安装pandas,而我正在使用Python3
So I had two diectories with Python2 --> C:\Python27
and Python365 --> C:\Python365
.
所以我有两个带有Python2 --> C:\Python27
和的字典Python365 --> C:\Python365
。
To resolve this error:
要解决此错误:
Run pip install pandas
in cmd
. If library pandas
is already installed you'll see something like following.
运行pip install pandas
在cmd
。如果库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 pandas
is installed in Python2
directory i.e. c:\python27\lib\site-packages (0.23.4)
从上面命令的输出中你可以看到它pandas
安装在Python2
目录 iec:\python27\lib\site-packages (0.23.4)
Run python
command in cmd
to check which Python
version 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 Python3
while pandas
is installed in Python2
directory`
您可以看到我正在使用Python3
whilepandas
安装在Python2
目录中`
To install the pandas
and other libraries in Python3
go to scripts folder
in Python3 directory i.e. C:\Python365\Scripts
Open Command Window
and run pip install pandas
要安装pandas
在和其他图书馆Python3
转到scripts folder
在Python3 directory i.e. C:\Python365\Scripts
打开Command Window
和运行pip install pandas
Or you can use the complete path of pip in Python3 directory
on cmd
to run the intsall
command i.e. C:\Users\vichitrak>C:\Python365\Scripts\pip install pandas
或者你可以使用complete path of pip in Python3 directory
oncmd
来运行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++”的问题。
- 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)"
- After successful installation, use
pip install pandas
to install pandas - If
pip
is not installed, then download thr pandas source package with extensiontar.gz
and place it in directory wherever you want after extracting. opencmd.exe
and navigate to the path where pandas folder is extracted & placed usingcd C:/pandas
. Then install it using thepython setup.py install
- 为此,首先您需要使用链接中给出的说明安装“Microsoft Visual C++”:“[需要Microsoft Visual C++ 14.0(无法找到 vcvarsall.bat)”
- 安装成功后,使用
pip install pandas
安装pandas - 如果
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