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

Python3.8.1环境下无法安装mysql==0.0.2问题求助

无法安装mysql==0.0.2(Python3.8.1环境)

问题概述

在Python3.8.1环境中可正常安装mysql==0.0.3,但安装mysql==0.0.2时触发setuptools相关错误,核心报错为AttributeError: 'list' object has no attribute 'split'。

执行命令及报错详情

(venv) C:\Users\xyz\Envs\>pip install mysql==0.0.2
Collecting mysql==0.0.2
  Using cached mysql-0.0.2.tar.gz (1.9 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\\users\\xyz\\scripts\\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = \"C:\\Users\\xyz\\AppData\\Local\\Temp\\pip-install-rygxsfpt\\mysql\\setup.py\"; __file__=\"C:\\Users\\xyz\\AppData\\Local\\Temp\\pip-install-rygxsfpt\\mysql\\setup.py\";f=getattr(tokenize, \"open\", open)(__file__);code=f.read().replace(\"\r\n\", \"\n\");f.close();exec(compile(code, __file__, \"exec\"))' egg_info --egg-base 'C:\Users\xyz\AppData\Local\Temp\pip-install-rygxsfpt\mysql\pip-egg-info'
         cwd: C:\Users\xyz\AppData\Local\Temp\pip-install-rygxsfpt\mysql\
    Complete output (32 lines):
    WARNING: `mysql` is a virtual package. Please use `%s` as a dependency directly.

    running egg_info
    creating C:\Users\xyzAppData\Local\Temp\pip-install-rygxsfpt\mysql\pip-egg-info\mysql.egg-info
    writing C:\Users\xyzAppData\Local\Temp\pip-install-rygxsfpt\mysql\pip-egg-info\mysql.egg-info\PKG-INFO
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\xyz\AppData\Local\Temp\pip-install-rygxsfpt\mysql\setup.py", line 33, in <module>
        setup(
      File "c:\users\xyz\lib\site-packages\setuptools\__init__.py", line 87, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\xyz\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
.....
.....
.....
 
        lines = header.split('\n')
    AttributeError: 'list' object has no attribute 'split'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法

临时解决(强制安装mysql==0.0.2)

  • 降级setuptools到兼容版本,执行:
    pip install setuptools==44.0.0
    
  • 再次尝试安装mysql==0.0.2:
    pip install mysql==0.0.2
    
  • 安装完成后可升级回新版setuptools:
    pip install --upgrade setuptools
    

长期推荐方案

mysql是官方标记的虚拟包,本身不提供实际功能,仅作为占位存在。建议直接安装成熟的MySQL驱动包,比如:

  • 安装pymysql:
    pip install pymysql
    
  • 或安装官方驱动mysql-connector-python:
    pip install mysql-connector-python
    

内容的提问来源于stack exchange,提问作者OneTouchForHeight

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 04:01:07