试图遵循 Django 教程,但我无法安装 mysqlclient

该教程声称我可以使用以下命令执行此操作:
pip install mysqlclient
但这会产生此错误:

Collecting mysqlclient   Using cached mysqlclient-1.3.12.tar.gz
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-rrolctwh/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-build-rrolctwh/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-build-rrolctwh/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found


----------------------------------------  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rrolctwh/mysqlclient/

我安装了最新的 pip 和 virtualenv。

我希望能够安装 mysqlclient 以便我可以继续本教程。

最佳答案

您还应该安装 mysql 和 python 开发头文件和库:
https://github.com/PyMySQL/mysqlclient-python#prerequisites

关于python - Ubuntu 17 : Can't install mysqlclient,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47370385/

10-13 02:04