安装Pandas报ImportError: DLL load failed: 找不到指定的模块的错误

48 篇文章 1 订阅
2 篇文章 0 订阅
安装

命令:pip install pandas

C:\Users\user>pip install pandas
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/d2/81/a1514c993ad8261a2053f356c3ea9a6ad41871a09a8ef9cf46789e371a63/pandas-1.0.3-cp36-cp36m-win_amd64.whl
Collecting numpy>=1.13.3 (from pandas)
  Downloading https://files.pythonhosted.org/packages/5c/74/04e9fb4ed91aaca3bf762429c3567c9523c311b1ef615795737e16f3cd23/numpy-1.18.4-cp36-cp36m-win_amd64.whl (12.8MB)
    100% |████████████████████████████████| 12.8MB 693kB/s
Collecting pytz>=2017.2 (from pandas)
  Downloading https://files.pythonhosted.org/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 900kB/s
Collecting python-dateutil>=2.6.1 (from pandas)
  Using cached https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas)
  Using cached https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Installing collected packages: numpy, pytz, six, python-dateutil, pandas
Successfully installed numpy-1.18.4 pandas-1.0.3 python-dateutil-2.8.1 pytz-2020.1 six-1.14.0
查看已安装插件

命令:pip list

C:\Users\user>pip list
Package         Version
--------------- -------
numpy           1.18.4
pandas          1.0.3
pip             18.1
python-dateutil 2.8.1
pytz            2020.1
setuptools      40.6.2
six             1.14.0
导包测试
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\api.py", line 29, in <module>
    from pandas.core.groupby import Grouper, NamedAgg
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\groupby\generic.py", line 60, in <module>
    from pandas.core.frame import DataFrame
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\frame.py", line 124, in <module>
    from pandas.core.series import Series
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\series.py", line 4572, in <module>
    Series._add_series_or_dataframe_operations()
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\generic.py", line 10349, in _add_series_or_dataframe_operations
    from pandas.core.window import EWM, Expanding, Rolling, Window
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window\__init__.py", line 1, in <module>
    from pandas.core.window.ewm import EWM  # noqa:F401
  File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window\ewm.py", line 5, in <module>
    import pandas._libs.window.aggregations as window_aggregations
ImportError: DLL load failed: 找不到指定的模块。
初步判定原因

采用pip install pandas安装方式默认会安装最新版,可能会版本不兼容,导致导包出现错误。

解决方案

适当降低pandas的版本号,先查看当前安装的版本,然后卸载,重新指定版本安装:

  • 查看已安装pandas的版本号(Version): pip show pandas
C:\Users\user> pip show pandas
Name: pandas
Version: 1.0.3
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: c:\users\user\appdata\local\programs\python\python36\lib\site-packages
Requires: pytz, numpy, python-dateutil
Required-by:
  • 查看已安装插件当前版本跟最新版本: pip list --outdated
C:\Users\user>pip list --outdated
Package    Version Latest Type
---------- ------- ------ -----
pandas     1.0.0   1.0.3  wheel
pip        18.1    20.1   wheel
setuptools 40.6.2  46.3.0 wheel
  • 安装指定版本: pip install 库名==版本号
C:\Users\user> pip install pandas==1.0.3
  • 更新升级插件版本: pip install --upgrade 要升级的包名
pip install --upgrade pandas
  • 查看pandas可安装的所有版本号(乱传入一个超级大的版本号,即可获取所有可用版本号)
C:\Users\user> pip install pandas==22222222
Collecting pandas==22222
  Could not find a version that satisfies the requirement pandas==22222 (from versions: 0.1, 0.2b0, 0.2b1, 0.2, 0.3.0b0, 0.3.0b2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0rc1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0rc1, 0.8.0rc2, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0rc1, 0.19.0, 0.19.1, 0.19.2, 0.20.0rc1, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0rc1, 0.21.0, 0.21.1, 0.22.0, 0.23.0rc2, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0rc1, 0.24.0, 0.24.1, 0.24.2, 0.25.0rc0, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0rc0, 1.0.0, 1.0.1, 1.0.2, 1.0.3)
No matching distribution found for pandas==22222

其中的from versions:就是囊括了所有可用版本。

  • 卸载已安装的库:pip uninstall 库名
C:\Users\user>pip uninstall pandas
Uninstalling pandas-1.0.3:
  Would remove:
    c:\users\user\appdata\local\programs\python\python36\lib\site-packages\pandas-1.0.3.dist-info\*
    c:\users\user\appdata\local\programs\python\python36\lib\site-packages\pandas\*
Proceed (y/n)? y
  Successfully uninstalled pandas-1.0.3
  • 再次安装低版本pandas库
C:\Users\user>pip install pandas==1.0.0
Collecting pandas==1.0.0
  Downloading https://files.pythonhosted.org/packages/b7/6d/3eaa70da7dac8ca1bc5a26d50d94791aec8d346bc1d326c4d240aa64aca6/pandas-1.0.0-cp36-cp36m-win_amd64.whl (8.8MB)
    100% |████████████████████████████████| 8.8MB 666kB/s
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\user\appdata\local\programs\python\python36\lib\site-packages (from pandas==1.0.0) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\user\appdata\local\programs\python\python36\lib\site-packages (from pandas==1.0.0) (2020.1)
Requirement already satisfied: numpy>=1.13.3 in c:\users\user\appdata\local\programs\python\python36\lib\site-packages (from pandas==1.0.0) (1.18.4)
Requirement already satisfied: six>=1.5 in c:\users\user\appdata\local\programs\python\python36\lib\site-packages (from python-dateutil>=2.6.1->pandas==1.0.0) (1.14.0)
Installing collected packages: pandas
Successfully installed pandas-1.0.0
  • 最后测试版本库是否兼容
C:\Users\user>python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>

没有报错,安装成功!

附加
  • 查看import库版本
>>> import pandas
>>> pandas.__version__
'1.0.0'
  • 查看内置命令的版本: 插件 - V
C:\Users\user>python -V
Python 3.6.8

C:\Users\user>pip -V
pip 18.1 from c:\users\user\appdata\local\programs\python\python36\lib\site-packages\pip (python 3.6)
  • pip更新升级
python -m pip install --upgrade pip
  • 卸载pip
python -m pip uninstall pip

如果觉得文章对您有帮助,欢迎点赞、收藏、评论讨论!
在这里插入图片描述

  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
ImportError: DLL load failed while importing _gdcmswig: 不到指定模块。这个错误通常是由于缺少所需的库或模块引起的。根据提供的引用,我可以看出这个错误与cv2、numpy和pandas类似,都是由于不到指定模块而导致的。在Python中,这种错误通常是由于缺少对应的库文件或模块文件所致。 要解决这个问题,你可以尝试以下几个步骤: 1. 确保你已经正确安装了相关的库或模块。你可以使用pip或conda等包管理工具来安装这些库。在安装之前,最好先升级你的包管理工具,然后再安装需要的库。 2. 检查你的环境变量是否设置正确。有时候,系统无法到库文件或模块文件是因为环境变量没有正确配置。你可以检查一下你的环境变量,确保路径中包含了所需的库或模块的位置。 3. 确保你的库或模块的版本与你的Python版本兼容。有时候,不同版本的库或模块可能不兼容,导致加载失败。你可以尝试安装与你的Python版本兼容的库或模块。 4. 如果你使用的是PyCharm或其他集成开发环境,确保你的项目配置正确。有时候,项目的配置可能不正确,导致无法加载所需的库或模块。你可以检查一下项目配置,确保路径设置正确。 总结一下,要解决ImportError: DLL load failed while importing _gdcmswig: 不到指定模块错误,你可以尝试安装正确的库或模块,检查环境变量的配置,确保版本兼容性,以及检查项目配置是否正确。希望这些步骤能够帮助你解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [python ImportError: DLL load failed while import cv2: 不到指定模块。](https://download.csdn.net/download/zz975896590/85710278)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ImportError: DLL load failed while importing cv2: 不到指定模块。(解决方案)](https://blog.csdn.net/thy0000/article/details/122648645)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [ImportError: DLL load failed while importing mtrand:不到指定的程序。](https://blog.csdn.net/weixin_43694829/article/details/115527076)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值