繁体   English   中英

为Anaconda python安装PyMySQL

[英]Installing PyMySQL for Anaconda python

我已经安装了两个版本的python。

win32上的Python 2.7.2(默认,2011年6月12日,15:08:59)[MSC v.1500 32位(英特尔)]

Python 2.7.7 | Anaconda 2.0.1(64位)| (默认情况下,2014年6月11日,10:40:02)[winv上的MSC v.1 500 64位(AMD64)]

我正在尝试为anaconda python包安装PyMySQL,问题是当我尝试安装它时,它安装在Python 2.7.2中。如何我可以sucesccufly为anaconda版本安装库。 我尝试使用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目录中,但它也没有工作。 我还能尝试什么? 在这不可能我在anaconda中使用哪个库来访问mysql数据服务器?

我一直在努力解决这个问题,然后才意识到问题是通过用python调用python脚本来解决的(有点奇怪)。 我在Windows上使用Anaconda。

从python导入工作正常:

(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

使用“python”运行:

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

我可以使用命令conda install pymysql在我的ubuntu系统上conda install pymysql ,如果有任何文件权限问题,运行命令sudo chmod -R 777 youAnacondaPath/anaconda3

我面临同样的问题。 并且问题由conda install pymysql解决。

暂无
暂无

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

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