windows上python安裝 支持mysql模塊

windows環境:
python版本是:Python 2.7.12
mysql版本:mysql Ver 14.14 Distrib 5.7.24, for Win64 (x86_64)
1.首先打開cmd,具體看下面代碼

Microsoft Windows [版本 6.1.7601]
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。

C:\Users\weiruoyu>pip install MySQL-python
Collecting MySQL-python
Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe
7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
47% |███████████████ | 51kB 268kB/s eta 0:00:
56% |██████████████████ | 61kB 302kB/s eta 0:
65% |█████████████████████ | 71kB 333kB/s eta
75% |████████████████████████ | 81kB 365kB/s
84% |███████████████████████████ | 92kB 382kB
94% |██████████████████████████████ | 102kB 4
100% |████████████████████████████████| 112k
B 525kB/s
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;file='c:\users\weiruoyu\appdata\local\temp\pip-build-guukdn
\MySQL-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(file)
.read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\wei
ruoyu\appdata\local\temp\pip-ka2sd6-record\install-record.txt --single-version-e
xternally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb__init.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
creating build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\
init__.py -> build\lib.win-amd64-2.7\MySQLdb\con
stants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants

copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\c

onstants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants

copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constan

ts
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\cons
tants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\const
ants
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27

----------------------------------------

Command "c:\python27\python.exe -u -c "import setuptools, tokenize;file='c:\
\users\weiruoyu\appdata\local\temp\pip-build-guukdn\MySQL-python\setup.py
';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n',
'\n'), file, 'exec'))" install --record c:\users\weiruoyu\appdata\local\temp
\pip-ka2sd6-record\install-record.txt --single-version-externally-managed --comp
ile" failed with error code 1 in c:\users\weiruoyu\appdata\local\temp\pip-build-
guukdn\MySQL-python\
You are using pip version 8.1.1, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

C:\Users\weiruoyu>python -m pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828d
fc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)

34% |███████████▏                    | 471kB 1.6MB/s eta 0:00:01
35% |███████████▍                    | 481kB 1.5MB/s eta 0:00:01
36% |███████████▋                    | 491kB 1.5MB/s eta 0:00:01
37% |███████████▉                    | 501kB 1.3MB/s eta 0:00:01
37% |████████████                    | 512kB 1.3MB/s eta 0:00:01
38% |████████████▍                   | 522kB 1.3MB/s eta 0:00:0
39% |████████████▋                   | 532kB 1.3MB/s eta 0:00:0
40% |████████████▉                   | 542kB 1.3MB/s eta 0:00:0
40% |█████████████                   | 552kB 1.3MB/s eta 0:00:0
41% |█████████████▎                  | 563kB 1.2MB/s eta 0:00:
42% |█████████████▋                  | 573kB 1.2MB/s eta 0:00:
43% |█████████████▉                  | 583kB 1.2MB/s eta 0:00:
43% |██████████████                  | 593kB 1.2MB/s eta 0:00:
44% |██████████████▎                 | 604kB 1.3MB/s eta 0:00
45% |██████████████▌                 | 614kB 1.3MB/s eta 0:00
46% |██████████████▊                 | 624kB 1.3MB/s eta 0:00
46% |███████████████                 | 634kB 1.3MB/s eta 0:00
47% |███████████████▎                | 645kB 1.3MB/s eta 0:0
48% |███████████████▌                | 655kB 1.3MB/s eta 0:0
49% |███████████████▊                | 665kB 1.3MB/s eta 0:0
49% |████████████████                | 675kB 1.2MB/s eta 0:0
50% |████████████████▏               | 686kB 1.2MB/s eta 0:
51% |████████████████▌               | 696kB 1.1MB/s eta 0:
52% |████████████████▊               | 706kB 1.0MB/s eta 0:
52% |█████████████████               | 716kB 1.0MB/s eta 0:
53% |█████████████████▏              | 727kB 890kB/s eta 0
54% |█████████████████▍              | 737kB 806kB/s eta 0
55% |█████████████████▊              | 747kB 806kB/s eta 0
55% |██████████████████              | 757kB 781kB/s eta 0
56% |██████████████████▏             | 768kB 775kB/s eta
57% |██████████████████▍             | 778kB 711kB/s eta
58% |██████████████████▋             | 788kB 616kB/s eta
59% |██████████████████▉             | 798kB 652kB/s eta
59% |███████████████████▏            | 808kB 682kB/s eta
60% |███████████████████▍            | 819kB 628kB/s eta
61% |███████████████████▋            | 829kB 696kB/s eta
62% |███████████████████▉            | 839kB 682kB/s eta
62% |████████████████████            | 849kB 691kB/s eta
63% |████████████████████▍           | 860kB 682kB/s et
64% |████████████████████▋           | 870kB 636kB/s et
65% |████████████████████▉           | 880kB 691kB/s et
65% |█████████████████████           | 890kB 731kB/s et
66% |█████████████████████▎          | 901kB 628kB/s e
67% |█████████████████████▌          | 911kB 648kB/s e
68% |█████████████████████▉          | 921kB 682kB/s e
68% |██████████████████████          | 931kB 682kB/s e
69% |██████████████████████▎         | 942kB 731kB/s
70% |██████████████████████▌         | 952kB 624kB/s
71% |██████████████████████▊         | 962kB 652kB/s
71% |███████████████████████         | 972kB 682kB/s
72% |███████████████████████▎        | 983kB 632kB/s
73% |███████████████████████▌        | 993kB 696kB/s
74% |███████████████████████▊        | 1.0MB 731kB/s
74% |████████████████████████        | 1.0MB 742kB/s
75% |████████████████████████▏       | 1.0MB 682kB/
76% |████████████████████████▌       | 1.0MB 628kB/
77% |████████████████████████▊       | 1.0MB 652kB/
77% |█████████████████████████       | 1.1MB 731kB/
78% |█████████████████████████▏      | 1.1MB 628kB
79% |█████████████████████████▍      | 1.1MB 648kB
80% |█████████████████████████▋      | 1.1MB 682kB
80% |██████████████████████████      | 1.1MB 673kB
81% |██████████████████████████▏     | 1.1MB 731k
82% |██████████████████████████▍     | 1.1MB 624k
83% |██████████████████████████▋     | 1.1MB 687k
83% |██████████████████████████▉     | 1.1MB 682k
84% |███████████████████████████▏    | 1.1MB 628
85% |███████████████████████████▍    | 1.2MB 644
86% |███████████████████████████▋    | 1.2MB 731
86% |███████████████████████████▉    | 1.2MB 736
87% |████████████████████████████    | 1.2MB 682
88% |████████████████████████████▎   | 1.2MB 63
89% |████████████████████████████▋   | 1.2MB 63
90% |████████████████████████████▉   | 1.2MB 68
90% |█████████████████████████████   | 1.2MB 63
91% |█████████████████████████████▎  | 1.2MB 6
92% |█████████████████████████████▌  | 1.2MB 7
93% |█████████████████████████████▊  | 1.3MB 7
93% |██████████████████████████████  | 1.3MB 6
94% |██████████████████████████████▎ | 1.3MB
95% |██████████████████████████████▌ | 1.3MB
96% |██████████████████████████████▊ | 1.3MB
96% |███████████████████████████████ | 1.3MB
97% |███████████████████████████████▎| 1.3MB
98% |███████████████████████████████▌| 1.3MB
99% |███████████████████████████████▊| 1.3MB
99% |████████████████████████████████| 1.4MB
100% |████████████████████████████████| 1.4M

B 419kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-19.0.3

C:\Users\weiruoyu>
C:\Users\weiruoyu>
C:\Users\weiruoyu>
C:\Users\weiruoyu>pip install mysql-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Ple
ase upgrade your Python as Python 2.7 won't be maintained after that date. A fut
ure version of pip will drop support for Python 2.7.
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68deb
e7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;file='c:\users\weiruoyu\appdata\local\temp\pip-install-_ngn
rm\mysql-python\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.r
ead().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" ins
tall --record c:\users\weiruoyu\appdata\local\temp\pip-record-f178ns\install-rec
ord.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb__init.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
creating build\lib.win-amd64-2.7\MySQLdb\constants
copying MySQLdb\constants\
init__.py -> build\lib.win-amd64-2.7\MySQLdb\con
stants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants

copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\c

onstants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants

copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constan

ts
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\cons
tants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\const
ants
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27

----------------------------------------

Command "c:\python27\python.exe -u -c "import setuptools, tokenize;file='c:\
\users\weiruoyu\appdata\local\temp\pip-install-_ngnrm\mysql-python\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\w
eiruoyu\appdata\local\temp\pip-record-f178ns\install-record.txt --single-version
-externally-managed --compile" failed with error code 1 in c:\users\weiruoyu\app
data\local\temp\pip-install-_ngnrm\mysql-python\

C:\Users\weiruoyu>pip install mysql-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Ple
ase upgrade your Python as Python 2.7 won't be maintained after that date. A fut
ure version of pip will drop support for Python 2.7.
Requirement already satisfied: mysql-python in c:\python27\lib\site-packages (1.
2.3)
1.1輸入:pip install MySQL-python報錯了 error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27 ,根據提示,接着輸入
1.2輸入:python -m pip install --upgrade pip 依然報錯
1.3再次輸入安裝:pip install mysql-python還是報錯,這個時候去外面下載
MySQL-python Windows下EXE安裝文件下載(32/64位)
安裝過程一致下一步,安裝完成後執行1.4
1.4輸入安裝命令:pip install mysql-python 正常

本次安裝參考了:windows下python操作mysql模塊安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章