之前一直是在centos上使用python操作mysql資料庫,mysqldb模組使用一直沒有問題。為了使用方便,今天想在windows下安裝mysqldb,卻遇到了一系列的問題。現將安裝過程中遇到的問題記錄如下:
2、解壓後,進入其目錄,執行:python setup.py install
d:\myfile\frompolo\python\mysql-python-1.2.3>pythonsetup.py install
traceback (most recent call last):
file "d:\myfile\frompolo\python\mysql-python-1.2.3\setup.py",line 5, in
from setuptools import setup, extension
importerror:no module named setuptools 3、
機器上沒有安裝setuptoos,在setuptoos的官網上,找到如下資訊:
4、右鍵儲存ez_setup.py檔案後,進入該檔案所存放的目錄下,執行:python ez_setup.py
d:\myfile\frompolo\python>python ez_setup.py
downloading
installing setuptools
running install
running bdist_egg
running egg_info
processing setuptools-15.1-py2.6.egg
copying setuptools-15.1-py2.6.egg toc:\python26\lib\site-packages
adding setuptools 15.1 to easy-install.pthfile
installing easy_install-script.py script toc:\python26\scripts
installing easy_install.exe script toc:\python26\scripts
installing easy_install.exe.manifest scriptto c:\python26\scripts
installing easy_install-2.6-script.pyscript to c:\python26\scripts
installing easy_install-2.6.exe script toc:\python26\scripts
installing easy_install-2.6.exe.manifestscript to c:\python26\scripts
installed c:\python26\lib\site-packages\setuptools-15.1-py2.6.egg
processing dependencies forsetuptools==15.1
finished processing dependencies forsetuptools==15.1
d:\myfile\frompolo\python>
5、setuptools安裝完成後,開始安裝mysqldb模組。
6、進入mysqldb安裝介質的根目錄,執行安裝命令:
d:\myfile\frompolo\python\mysql-python-1.2.3>setup.py install
running install
running bdist_egg
running egg_info
writing mysql_python.egg-info\pkg-info
writing top-level names tomysql_python.egg-info\top_level.txt
writing dependency_links tomysql_python.egg-info\dependency_links.txt
reading manifest file'mysql_python.egg-info\sources.txt'
reading manifest template 'manifest.in'
warning: no files found matching 'manifest'
warning: no files found matching'changelog'
warning: no files found matching 'gpl'
writing manifest file'mysql_python.egg-info\sources.txt'
installing library code tobuild\bdist.win32\egg
running install_lib
running build_py
copying mysqldb\release.py ->build\lib.win32-2.6\mysqldb
running build_ext
building '_mysql' extension
error: microsoft visual c++ 9.0 is required(unable to find vcvarsall.bat). get it from
7、從錯誤資訊看,還需要安裝微軟的visualc++ compiler。開啟錯誤資訊中的url,竟然是:
8、c++ complier安裝完成後,再執行安裝命令:
d:\myfile\frompolo\python\mysql-python-1.2.3>setup.py install
running install
running bdist_egg
running egg_info
processingmysql_python-1.2.3-py2.6-win32.egg
copying mysql_python-1.2.3-py2.6-win32.eggto c:\python26\lib\site-packages
adding mysql-python 1.2.3 toeasy-install.pth file
installed c:\python26\lib\site-packages\mysql_python-1.2.3-py2.6-win32.egg
processing dependencies formysql-python==1.2.3
finishedprocessing dependencies for mysql-python==1.2.3
9、這回算是把mysqldb模組安裝上了。
10、進入python的repl互動命令列介面進行測試:
d:\myfile\frompolo\python\mysql-python-1.2.3>python
python 2.6.6 (r266:84297, aug 24 2010, 18:46:32)[msc v.1500 32 bit (intel)] on
win32
>>>import mysqldb
>>>exit()
可以正常import,模組安裝成功。
11、執行指令碼往mysql插入資料時,又遇到了問題:
traceback (most recent call last):
file "xmlparse4domain_v0.2.py", line 93, in
cur_i.execute(sql_insert)
file "build\bdist.win32\egg\mysqldb\cursors.py", line 174, inexecute
file "build\bdist.win32\egg\mysqldb\connections.py", line 36,in defaulterrorh
這個是由字元編碼問題引起的,因為往mysql插入的資料中包含有中文。除了在程式開頭寫好「#-*- coding: utf-8 -*-」、連線資料庫時設定「conn=mysqldb.connect(host="192.168.10.1",user="root",passwd="123456",db="test",charset="utf8")」外,在進行插入操作前做一下編碼轉換:
12、自此,mysql安裝完成,亦可正常使用。
ps:網上有說windows下安裝mysqldb模組,還需要兩個dll檔案,但我在安裝過程並沒有遇到該問題,具體請參見如下url:
基於rmp在linux環境下安裝mysql
很久沒手動安裝過mysql了現在就在這裡記錄一下一些坑 具體安裝流程可以參考 菜鳥教程 安裝完畢後,mysql安裝目前在 usr bin mysql root izwz9d32g6iuzyahpuwt0tz usr which mysql usr bin mysql配置檔案在 etc my.cnf ...
在windows下安裝webpy
prerequisite 1.install python 2.download webpy steps 1.解壓webpy壓縮包 2.type win r type cmd 在webpy安裝目錄下 type python setup.py install import web urls index...
Theano 在windows下安裝
theano win8 一切為了 deep learning 選擇安裝方式 anacondace 學術免費 simply download and execute the installer from anacondace downlowad page then download and execu...