簡體   English   中英

使用pip install時出現的問題

[英]problems when using pip install

我對使用 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.

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

也許您不小心使用了系統上安裝的python2.7版本。

您可以將特定版本的 python 用於 pip:

python3 -m pip install mysql-python

讓我解釋一下,每個 MacOS 或 Linux 系統默認都有兩個 Python 版本(2.7 和 3.x),並且這兩個版本都有一個與之相關的 pip 模塊,換句話說,你有一個 Python 2.7 的 pip 模塊和Python 3.x 的其他 pip 模塊。

但是,我假設您的項目使用的是 python3,因此,您必須指定要使用的 pip 模塊。

避免此問題的其他方法是使用虛擬環境管理器,例如 pipenv 或內置的 virtualenv 模塊。

看起來您的 pip 包沒有安裝模塊“ConfigParser”。 您應該能夠通過運行來安裝它:

pip install ConfigParser

或者,根據您的 Python 版本,嘗試安裝 mysqlclient:

pip install mysqlclient

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM