我是python新手,我正在尝试django框架,它涉及一些mysql,在尝试时遇到了这个错误 pip install mysqlclient
在cmd信息的下面我得到了这个。
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\users\ronanl~1\envs\py1\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\RONANL~1\\AppData\\Local\\Temp\\pip-install-pkbqy3t3\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\RONANL~1\AppData\Local\Temp\pip-record-moxwf7lu\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\ronanl~1\envs\py1\include\site\python3.7\mysqlclient:
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
copying _mysql_exceptions.py -> build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
creating build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" "-Ic:\users\ronan lina\appdata\local\programs\python\python37-32\include" "-Ic:\users\ronan lina\appdata\local\programs\python\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
>
>
> Command "c:\users\ronanl~1\envs\py1\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\RONANL~1\\AppData\\Local\\Temp\\pip-install-pkbqy3t3\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\RONANL~1\AppData\Local\Temp\pip-record-moxwf7lu\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\ronanl~1\envs\py1\include\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\RONANL~1\AppData\Local\Temp\pip-install-pkbqy3t3\mysqlclient\
有人知道怎么解决吗?
11条答案
按热度按时间lymgl2op1#
目前,mysql connector for python3.7在官方网站wesite中不可用,但是你可以通过安装特定windows和python版本的wheel来解决这个问题。此解决方案
pip install (ex/dir)/mysqlclient-1.3.13-cp37-cp37m-win_amd64.whl
对于win 64 bi和python 3.7请检查下面的链接并下载您系统的特定控制盘。使用“pip install(在我的例子中是文件名的完整路径,例如:-”pip install c:\users%user%\downloads\mysqlclient-1.3.13-cp37-cp37m-win\u amd64.whl)下载并安装特定版本的控制盘
tyu7yeag2#
确保你已经用python做了必要的工作。。。
在全球范围内安装(非虚拟环境)
sudo apt-get install mysql-server
pip install --upgrade setuptools
我也遇到了同样的问题,因为我安装了默认的python2.7.15,而python3在为python做了必要的工作(作为python2)之后会收支平衡对我有用的东西是(实际上,最后一个是使它工作的原因,但我认为它们在我的python3虚拟环境中同样需要)
python3.7在virtualenv中
我还得经历。。
voase2hg3#
在我的例子中,我安装了32位版本的python,而不是64位版本。安装64位python就可以了。
qqrboqgw4#
从2019年开始,这里是如何平稳运行的
pip install mysqlclient
在macos上:brew info openssl
按照下面的命令做其他方法:
brew install/upgrade/reinstall mysql
:没有为我解决问题,但有很好的副作用,以确保您的安装是干净的。brew install mysql-connector-c
:要使这项工作,你必须取消链接mysql,这破坏了你的设置,它没有解决我的问题。w8biq8rn5#
在系统中安装mysqlclient for python 3.7之前,需要安装以下依赖项。
sudo apt-get install python3.7-dev default-libmysqlclient-dev
我希望这对你有帮助。dfty9e196#
使用Python并执行
conda install mysqlclient
hrirmatl7#
您必须安装“mysqlclient-1.4.1-cp37-cp37m-win32.whl”(32位)文件
从下载32位文件https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
如果文件在下载文件夹中,请在cmd中写入命令
一。
cd C:\Users\Nour Noby\Downloads
[“nour noby”应更改]二。
pip install mysqlclient-1.4.1-cp37-cp37m-win32.whl
[“mysqlclient-1.4.1-cp37-cp37m-win32.whl”应替换为下载的文件名]。3pvhb19x8#
我使用以下命令安装了它,现在运行良好(在mac上):
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
请参阅连接的答案:安装mysql时出错python:library not found for-lsslruyhziif9#
我在ubuntu上安装了以下库,之后,问题得到了解决。
然后我可以使用以下命令安装mysqlclient
guicsvcw10#
使用此命令:
sudo apt-get install libssl-dev
30byixjq11#
先试试这个
然后