无法安装mysqlclient [英] Cannot install mysqlclient

查看:75
本文介绍了无法安装mysqlclient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Django 框架中使用 python3.8,为此我必须安装 mysqlclient.但是当我尝试时错误来了

pip3 安装mysqlclient

像这样输出错误.

收集mysqlclient使用缓存的 https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz错误:命令出错,退出状态为 1:命令:/home/LPython/my_env/bin/python3.8 -c 'import sys, setuptools, tokenize;sys.argv[0] = '"'"'/tmp/pip-install-fgg27tgk/mysqlclient/setup.py'"'"';__file__='"'"'/tmp/pip-install-fgg27tgk/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(代码,__file__,'"'"'exec'"'"'))' egg_info --egg-base/tmp/pip-install-fgg27tgk/mysqlclient/pip-egg-infocwd:/tmp/pip-install-fgg27tgk/mysqlclient/完整输出(11 行):回溯(最近一次调用最后一次):文件<string>",第 1 行,在 <module> 中文件/home/LPython/my_env/lib/python3.8/site-packages/setuptools/__init__.py",第20行,在<module>从 setuptools.dist 导入分发,功能文件/home/LPython/my_env/lib/python3.8/site-packages/setuptools/dist.py",第35行,在<module>从 setuptools 导入 windows_support文件/home/LPython/my_env/lib/python3.8/site-packages/setuptools/windows_support.py",第2行,在<module>导入 ctypes文件/usr/local/lib/python3.8/ctypes/__init__.py",第7行,在<module>from _ctypes 导入联合、结构、数组ModuleNotFoundError: 没有名为_ctypes"的模块---------------------------错误:命令出错,退出状态为 1:python setup.py egg_info 检查日志以获取完整的命令输出.

解决方案

我的问题解决了.当我安装python-3.8.0时,我没有编译它,这就是问题所在.我用的是Centos7,所以我去终端的root,先安装Python的先决条件再安装.

<预><代码># sudo yum install gcc openssl-devel bzip2-devel libffi-devel下载最新版本#wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz现在解压缩下载的包.编译 Python 源代码#cd Python-3.8.0#sudo ./configure --enable-optimizationsmake altinstall 用于防止替换默认的python 二进制文件/usr/bin/python.#sudo make altinstall从系统中删除下载的源存档文件#sudo rm Python-3.8.0.tgz检查 Python 版本#python3.8 -V然后我就可以通过以下方式安装 mysqlclient# pip3 安装 mysqlclient

I am using python3.8 in django framework, for that I have to install mysqlclient. But error is coming when I try

pip3 install mysqlclient

output like this as error.

Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /home/LPython/my_env/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fgg27tgk/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fgg27tgk/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 /tmp/pip-install-fgg27tgk/mysqlclient/pip-egg-info
         cwd: /tmp/pip-install-fgg27tgk/mysqlclient/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <module>
        from setuptools.dist import Distribution, Feature
      File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/dist.py", line 35, in <module>
        from setuptools import windows_support
      File "/home/LPython/my_env/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
        import ctypes
      File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方案

My problem is solved. When I installed python-3.8.0, I did not compile it, that was the problem. I am using Centos7, so I went to the root of the terminal, first install prerequisites for Python before installing it.


# sudo yum install gcc openssl-devel bzip2-devel libffi-devel

download latest version

#wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

Now extract the downloaded package.

Compile Python Source

#cd Python-3.8.0
#sudo ./configure --enable-optimizations

make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

#sudo make altinstall

remove downloaded source archive file from your system

#sudo rm Python-3.8.0.tgz

Check Python Version

#python3.8 -V 

Then I could be able to install mysqlclient by
# pip3 install mysqlclient



这篇关于无法安装mysqlclient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆