【问题标题】:problems when using pip install使用 pip install 时的问题
【发布时间】:2020-05-29 16:21:02
【问题描述】:

我对使用 pip 不是很有经验。当我尝试安装一些软件包时,我遇到了这个错误并且不知道这意味着什么。这发生在我尝试安装的多个软件包上。任何建议将不胜感激。

sudo pip install mysql-python
Password:
WARNING: The directory '/Users/yzr/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysql-python
  Downloading MySQL-python-1.2.5.zip (108 kB)
     |████████████████████████████████| 108 kB 2.2 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /Users/yzr/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-0kcqh5vw/mysql-python/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-0kcqh5vw/mysql-python/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 /private/tmp/pip-install-0kcqh5vw/mysql-python/pip-egg-info
         cwd: /private/tmp/pip-install-0kcqh5vw/mysql-python/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-0kcqh5vw/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/tmp/pip-install-0kcqh5vw/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

【问题讨论】:

标签: python python-3.x pip mysql-python


【解决方案1】:

我假设您使用的是 Unix 系统,例如 Linux 或 MacOS。

可能你不小心使用了系统上安装的python2.7版本。

您可以将特定版本的 python 用于 pip:

python3 -m pip install mysql-python

让我解释一下,每个 MacOS 或 Linux 系统默认都有两个 Python 版本(2.7 和 3.x),并且这两个版本都有一个与之相关的 pip 模块,换句话说,你有一个 pip 模块用于Python 2.7 和 Python 3.x 的其他 pip 模块。

但是,我假设您在项目中使用 python3,因此,您必须指定要使用的 pip 模块。

避免此问题的其他方法是使用虚拟环境管理器,例如 pipenv 或内置的 virtualenv 模块。

【讨论】:

    【解决方案2】:

    您的 pip 包似乎没有安装模块“ConfigParser”。你应该可以通过运行来安装它:

    pip install ConfigParser
    

    或者,根据您的 Python 版本,尝试安装 mysqlclient:

    pip install mysqlclient
    

    【讨论】:

      猜你喜欢
      • 2014-06-19
      • 1970-01-01
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 2013-07-18
      • 2022-11-08
      • 2021-08-01
      • 1970-01-01
      相关资源
      最近更新 更多