ten$1 发表于 2020-8-1 12:47:27

安装mysql库时失败

这个怎么解决才能成功安装库

**************deapple$ pip install mysql
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/mysql/
Collecting mysql
Using cached mysql-0.0.2.tar.gz (1.9 kB)
Collecting mysqlclient
Using cached mysqlclient-2.0.1.tar.gz (87 kB)
    ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv = '"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/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/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-pip-egg-info-jzjbmo18
         cwd: /private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/
    Complete output (12 lines):
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/setup.py", line 15, in <module>
      metadata, options = get_config()
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/setup_posix.py", line 65, in get_config
      libs = mysql_config("libs")
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-1d7098sg/mysqlclient/setup_posix.py", line 31, in mysql_config
      raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Twilight6 发表于 2020-8-1 13:23:18


试试这样把:

python -m pip install mysql -i https://pypi.tuna.tsinghua.edu.cn/simple

ten$1 发表于 2020-8-1 14:14:40

Twilight6 发表于 2020-8-1 13:23
试试这样把:

这样了

ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv = '"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/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/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-pip-egg-info-8ma3xtnw
         cwd: /private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/
    Complete output (12 lines):
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/setup.py", line 15, in <module>
      metadata, options = get_config()
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/setup_posix.py", line 65, in get_config
      libs = mysql_config("libs")
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-xcs5_ky6/mysqlclient/setup_posix.py", line 31, in mysql_config
      raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Twilight6 发表于 2020-8-1 14:15:34

ten$1 发表于 2020-8-1 14:14
这样了

你用 PyCharm 还是什么?

ten$1 发表于 2020-8-1 14:16:20

Twilight6 发表于 2020-8-1 14:15
你用 PyCharm 还是什么?

VSC

ten$1 发表于 2020-8-1 14:17:05

Twilight6 发表于 2020-8-1 14:15
你用 PyCharm 还是什么?

Mac终端上 输入的命令

Twilight6 发表于 2020-8-1 14:18:47

ten$1 发表于 2020-8-1 14:17
Mac终端上 输入的命令

试试升级下 pip:

python -m pip install --upgrade setuptools

ten$1 发表于 2020-8-1 14:24:01

Twilight6 发表于 2020-8-1 14:18
试试升级下 pip:

xiaojiayudeMacBook-Pro:~ xiaojiayudeapple$ python -m pip install mysql -i https://pypi.tuna.tsinghua.edu.cn/simple
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mysql
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bf/5f/b574ac9f70811df0540e403309f349a8b9fa1a25d3653824c32e52cc1f28/mysql-0.0.2.tar.gz (1.9 kB)
Collecting MySQL-python
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108 kB)
    ERROR: Command errored out with exit status 1:
   command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv = '"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-ZjhkYM/MySQL-python/setup.py'"'"'; __file__='"'"'/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-ZjhkYM/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/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-pip-egg-info-wj3wH0
         cwd: /private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-ZjhkYM/MySQL-python/
    Complete output (10 lines):
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/3r/0cbh6s212zb98slf61q37bs80000gn/T/pip-install-ZjhkYM/MySQL-python/setup.py", line 17, in <module>
      metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
      libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
      raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Twilight6 发表于 2020-8-1 14:31:32

ten$1 发表于 2020-8-1 14:24


电脑有多版本的Python, 2.7 和 3.8 吗?

ten$1 发表于 2020-8-1 14:34:52

Twilight6 发表于 2020-8-1 14:31
电脑有多版本的Python, 2.7 和 3.8 吗?

对,我也不知道怎么搞

Twilight6 发表于 2020-8-1 12:47:28

本帖最后由 Twilight6 于 2020-8-1 14:42 编辑

ten$1 发表于 2020-8-1 14:34
对,我也不知道怎么搞

试试这样:sudo pip install MySQL-python

看看这个文章能不能解决:https://blog.csdn.net/du_wood/article/details/84922312


页: [1]
查看完整版本: 安装mysql库时失败