简体   繁体   English

尝试安装mysql-python:“没有名为urllib3的模块”

[英]Trying to install mysql-python: “No module named urllib3”

I'm trying to look around on this issue but so far nothing I've found has fixed it. 我正在尝试解决这个问题,但到目前为止,我发现没有任何东西可以解决此问题。 I am not that familiar with Python and I'm working with someone else's script. 我对Python不太熟悉,并且正在使用其他人的脚本。 I am on Windows 10 (64-bit). 我在Windows 10(64位)上。

Executing this command: pip install mysql-python 执行此命令: pip install mysql-python

And getting this error: 并得到此错误:

Traceback (most recent call last):
File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar  # noqa
File "C:\Python27\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python27\lib\site-packages\pip\download.py", line 38, in <module>
from pip._vendor import requests, six
File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\Python27\lib\site-packages\pip\_vendor\requests\utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "C:\Python27\lib\site-packages\pip\_vendor\requests\compat.py", line 7, in <module>
from .packages import chardet
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module>
import urllib3
ImportError: No module named urllib3

The python module that you are trying to install will probably require you to compile it which makes the task much harder for a newbie. 您尝试安装的python模块可能会要求您对其进行编译,这会使新手的工作更加困难。

Instead, I would recommend you to use a pure-python module like https://github.com/PyMySQL/PyMySQL -- which is much easier to install because you do not have to compile it. 相反,我建议您使用https://github.com/PyMySQL/PyMySQL之类的纯python模块-安装起来容易得多,因为您不必编译它。

Usually I recommend anyone that is trying to work with databases in Python to use SQLAlchemy, mainly because this allows you to use a single interface when you deal with the database, one that does not depends on the database-driver being used. 通常,我建议任何尝试在Python中使用数据库的人使用SQLAlchemy,主要是因为这允许您在处理数据库时使用单个接口,而该接口不依赖于所使用的数据库驱动程序。

Read the answer from python3 sqlalchemy pymysql connect string in order to get an idea about how to use pymysql via sqlalchemy. 阅读来自python3 sqlalchemy pymysql connect字符串的答案,以获取有关如何通过sqlalchemy使用pymysql的想法。

wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59
tar xvf urllib3-1.16.tar.gz  && cd urllib3-1.1
python setup.py install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM