2014-09-12 123 views
1

我已經安裝了兩個版本的python。安裝PyMySQL for Anaconda python

的Python 2.7.2(默認情況下,2011年6月12日,15點08分59秒)[MSC v.1500 32位(英特爾)]在Win32

的Python 2.7.7 |阿納康達2.0.1(64-位)| (默認,2014年6月11日,10:40:02)[MSC v.1 500 64位(AMD64)]在win32

我試圖安裝PyMySQL for anaconda python包,問題是,當我嘗試安裝它,它安裝在Python 2.7.2中。我可以如何爲anaconda版本安裝庫。我試着用蟒蛇命令

conda install PyMySQ 

,但沒有工作 也試過

python.exe C:\Users\jimenez\Downloads\PyMySQL-0.6.2\setup.py install 

這裏是在蟒蛇目錄發生

C:\Anaconda>python.exe C:\Users\jimenez\Downloads\PyMySQL-0.6.2\setup.py install 
running install 
running bdist_egg 
running egg_info 
writing PyMySQL.egg-info\PKG-INFO 
writing top-level names to PyMySQL.egg-info\top_level.txt 
writing dependency_links to PyMySQL.egg-info\dependency_links.txt 
warning: manifest_maker: standard file 'setup.py' not found 

reading manifest file 'PyMySQL.egg-info\SOURCES.txt' 
writing manifest file 'PyMySQL.egg-info\SOURCES.txt' 
installing library code to build\bdist.win-amd64\egg 
running install_lib 
warning: install_lib: 'build\lib' does not exist -- no Python modules to install 


creating build\bdist.win-amd64\egg 
creating build\bdist.win-amd64\egg\EGG-INFO 
copying PyMySQL.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO 
copying PyMySQL.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO 
copying PyMySQL.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-I 
NFO 
copying PyMySQL.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO 
zip_safe flag not set; analyzing archive contents... 
creating 'dist\PyMySQL-0.6.2-py2.7.egg' and adding 'build\bdist.win-amd64\egg' t 
o it 
removing 'build\bdist.win-amd64\egg' (and everything under it) 
Processing PyMySQL-0.6.2-py2.7.egg 
Removing c:\anaconda\lib\site-packages\PyMySQL-0.6.2-py2.7.egg 
Copying PyMySQL-0.6.2-py2.7.egg to c:\anaconda\lib\site-packages 
PyMySQL 0.6.2 is already the active version in easy-install.pth 

Installed c:\anaconda\lib\site-packages\pymysql-0.6.2-py2.7.egg 
Processing dependencies for PyMySQL==0.6.2 
Finished processing dependencies for PyMySQL==0.6.2 

C:\Anaconda>python 
Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC v.1 
500 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
Anaconda is brought to you by Continuum Analytics. 
Please check out: http://continuum.io/thanks and https://binstar.org 
>>> import PyMySQL 
Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
ImportError: No module named PyMySQL 

,但它不工作要麼。我還能嘗試什麼?在這種情況下,我可以在anaconda中使用哪些庫來訪問mysql數據服務器?

+0

至於爲什麼你嘗試的第一步不起作用:它看起來像PyMySQL尚未被Anaconda支持:http://docs.continuum.io/anaconda/pkg-do cs.html但這並不意味着你不能自己安裝它,所以你嘗試的第二步應該工作。 – bernie 2014-09-12 21:04:06

+0

似乎anaconda安裝圖書館,但當我打電話時,它無法找到它 – 2014-09-12 21:10:05

+0

嘗試:'import sys; sys.path'來確保安裝它的目錄位於路徑 – bernie 2014-09-12 21:13:29

回答

0

在我意識到問題已通過使用python調用python腳本(有點奇怪)之前,我掙扎了一會兒。我在Windows上使用Anaconda。

從蟒蛇的導入工作正常:

(root) c:\python_scripts>python 
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import pymysql 
>>> quit() 

試圖直接從CMD運行的腳本(導入失敗):

(root) c:\python_scripts>script.py 
Traceback (most recent call last): 
    File "C:\python_scripts\GRAMR\CTA_monitor.py", line 5, in <module> 
    import pymysql 
ImportError: No module named pymysql 

運行與 「巨蟒」 的工作原理:

(root) c:\python_scripts>python script.py 
Script working ... 
0

我可以使用命令conda install pymysql在我的ubuntu系統上安裝pymysql,如果有任何文件權限問題,請運行命令sudo chmod -R 777 youAnacondaPath/anaconda3