无法在Linux Ubuntu上安装mysqlclient-python - python

我目前正在尝试在ubuntu上安装mysqlclient-python以与Django一起使用,并且遇到了问题。

我正在关注此页面:https://github.com/PyMySQL/mysqlclient-python

但是,当我运行“ pip install mysqlclient”时,出现以下错误:

running install_lib

copying build/lib.linux-x86_64-2.7/_mysql_exceptions.py -> /usr/local/lib/python2.7/dist-packages

error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/_mysql_exceptions.py'

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_robofish/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ynYYW0-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_robofish/mysqlclient
Storing debug log for failure in /home/robofish/.pip/pip.log

我检查了/usr/local/lib/python2.7/目录,它似乎是空的。这可能是问题吗?

python大神给出的解决方案

似乎您正在尝试在全局Python环境中安装mysqlclient。我强烈建议使用virtualenv创建隔离的Python环境。

如果仍要使用全局环境,请使用sudo pip install mysqlclient