You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入numpy或pandas时出现AttributeError: partially initialized module 'numpy.core.arrayprint' has no attribute 'array2string'错误的求助

导入numpy或pandas时出现AttributeError: partially initialized module 'numpy.core.arrayprint' has no attribute 'array2string'错误的求助

我的问题描述:

我之前尝试安装pandarallel时遇到了一些安装错误,现在哪怕只是简单导入pandas和numpy,都会触发下面的错误:

import pandas as pd
import numpy as np

AttributeError: partially initialized module 'numpy.core.arrayprint' has no attribute 'array2string' (most likely due to circular import)

不管我单独导入pandas还是numpy,都会出现这个错误。我查过类似的“partially initialized module”错误的解决方案,尝试重命名过本地的numpy相关文件,但没解决问题;也用pip升级过numpy,还是没用。有没有人能帮我解决这个问题?

可行的解决方向:

  • 先检查当前工作目录下有没有和numpy、pandas同名的文件(比如numpy.py、pandas.py),或是对应的__pycache__文件夹,这些本地文件会干扰官方库的正常导入,直接删除即可。
  • 尝试彻底卸载并重装numpy和pandas:
    1. 先执行卸载命令:
      pip uninstall -y numpy pandas
      
    2. 找到Python环境的site-packages目录,删除所有带numpy、pandas标识的文件夹和dist-info文件,确保没有残留文件。
    3. 重新安装稳定版本的库:
      pip install numpy==1.26.4 pandas==2.2.2
      
  • 检查Python环境是否存在依赖冲突:如果使用虚拟环境,确认自己在目标环境中操作;如果是全局环境,建议新建一个干净的虚拟环境,仅安装numpy和pandas测试是否正常。
  • 若使用conda环境,改用conda命令执行卸载重装,兼容性会更好:
    conda remove -y numpy pandas
    conda install numpy pandas
    

备注:内容来源于stack exchange,提问作者Karthik S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 17:32:58