首页 > 解决方案 > import pandas returning 'no module named pandas'

问题描述

I cannot use pandas in my script. It's my first time using a package, and it doesn't work. When I use pip install pandas the cmd prompt returns:

PS C:\Users\young> pip install pandas
3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (1.3.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\young\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas) (2.8.2)       
Requirement already satisfied: pytz>=2017.3 in c:\users\young\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas) (2021.1)
Requirement already satisfied: numpy>=1.17.3 in c:\users\young\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pandas) (1.21.1)
Requirement already satisfied: six>=1.5 in c:\users\young\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-dateutil>=2.7.3->pandas) (1.1PS C:\Users\young> pip3.9 install wheel
Requirement already satisfied: wheel in c:\users\young\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (0.36.2)
included in the snippet is pip install wheel, so I have that covered.

标签: pythonpandasmodulenotfounderror

解决方案


这是多安装 python 的典型问题。请检查您是否安装了多个 Python。如果是的话,那么......

您可以使用以下命令检查应保存已安装软件包的位置

导入 os os.path 然后使用以下终端指令安装

pip3 install pandas -t /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6


推荐阅读