[英]ImportError ''No Module Named Pandas'', installed by Miniconda
[英]ImportError: No module named pandas. Pandas installed pip
我使用 mac 终端来检查我的包裹:
pip list
我可以找到所有包都包括熊猫
但是当我
import pandas
它告诉我:
ModuleNotFoundError: 没有名为“pandas”的模块
顺便说一句,我的mac中有python2和python3,它们不是同一个目录,我怀疑python没有找到pandas的路径
首先,在您的项目文件夹中安装virtualenv
以保护您的项目目录,以避免与其他包冲突。
pip install virtualenv
安装完这个后,在你的项目根目录中一一运行这个命令:
virtualenv venv
source venv/bin/activate
现在你的目录是安全的,你可以在里面安装你需要的包。
pip install pandas
和其他你需要的。
因为您已经安装了virtualenv
并且安全运行,所以它不会与其他外部软件包发生冲突。
一步一步地使用所有步骤。 我希望它对您有用,可以避免此类错误。
谢谢。
尝试使用 pip 和 pip3 安装 pandas。
pip install pandas
pip3 install pandas
一个建议,使用 pyenv 并为您的本地目录设置一个 python 版本。
如果已经安装了 python v2.7,则为 v2.7 安装 numpy 和 pandas。 运行以下命令:
对于 Ubuntu / Linux -
sudo apt-get install python-numpy
sudo apt-get install python-pandas
如果已经安装了 python v3,则为 v3 安装 numpy 和 pandas。 运行以下命令:
对于 Ubuntu / Linux -
sudo apt-get install python3-numpy
sudo apt-get install python3-pandas
我在不同的目录中安装了Python2
和Python3
,但是我Python3
了这个错误,因为当我使用命令pip install pandas
它正在Python2
目录中安装Python2
而我正在使用Python3
所以我有两个 Python2 Python2 --> C:\\Python27
和Python365 --> C:\\Python365
。
要解决此错误:
在cmd
运行pip install pandas
。 如果库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)
从上面命令的输出中你可以看到pandas
安装在Python2
目录即c:\\python27\\lib\\site-packages (0.23.4)
Python2
c:\\python27\\lib\\site-packages (0.23.4)
在cmd
运行python
命令以检查您正在运行的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.
你可以看到,我使用的是Python3
而pandas
是安装在Python2
directory`
要在Python3
安装pandas
和其他库, Python3
转到Python3 directory ie C:\\Python365\\Scripts
scripts folder
, Python3 directory ie C:\\Python365\\Scripts
打开Command Window
并运行pip install pandas
或者你可以在cmd
上使用complete path of pip in Python3 directory
的complete path of pip in Python3 directory
运行intsall
命令即C:\\Users\\vichitrak>C:\\Python365\\Scripts\\pip install pandas
有时,这可能是由于“Microsoft Visual C++”的问题。
pip install pandas
安装pandaspip
,则下载扩展名为tar.gz
thr pandas 源包,解压后将其放置在您想要的目录中。 打开cmd.exe
并导航到使用cd C:/pandas
提取和放置 pandas 文件夹的路径。 然后使用python setup.py install
安装它最后,您应该收到成功消息,如已Finished processing dependencies for pandas==0.xx.0
我看到的错误是:
文件“c:\\SIP\\python\\visualws\\learn1\\pandas_test.py”,第 6 行,导入 pandas as pd ModuleNotFoundError: No module named 'pandas'
使用 Python 3.9.5 在 Windows 中执行以下命令:
C:\Users\deepy>pip install pandas
Collecting pandas
Downloading pandas-1.2.4-cp39-cp39-win_amd64.whl (9.3 MB)
|████████████████████████████████| 9.3 MB 3.3 MB/s
Collecting pytz>=2017.3
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 6.8 MB/s
Collecting numpy>=1.16.5
Downloading numpy-1.20.3-cp39-cp39-win_amd64.whl (13.7 MB)
|████████████████████████████████| 13.7 MB ...
Collecting python-dateutil>=2.7.3
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
|████████████████████████████████| 227 kB 6.4 MB/s
Collecting six>=1.5
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.3 pandas-1.2.4 python-dateutil-2.8.1 pytz-2021.1 six-1.16.0
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the 'c:\users\deepy\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.
它解决了问题,我可以使用import pandas
执行 .py 文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.