3

2 つのバージョンの Python をインストールしました。

Python 2.7.2 (デフォルト、2011 年 6 月 12 日 15:08:59) [MSC v.1500 32 ビット (Intel)] on win32

Python 2.7.7 |アナコンダ 2.0.1 (64 ビット)| (デフォルト、2014 年 6 月 11 日、10:40:02) [MSC v.1 500 64 ビット (AMD64)] (win32)

anaconda python パッケージ用の PyMySQL をインストールしようとしています。問題は、インストールしようとすると、Python 2.7.2 にインストールされることです。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データサーバーにアクセスするためにどのライブラリを使用できますか?

4

3 に答える 3

1

私はこれにしばらく苦労しましたが、Pythonスクリプトをpythonで呼び出すことで問題が解決したことに気付きました(ちょっと変です)。Windowsでアナコンダを使用しています。

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 ...
于 2016-10-09T20:36:34.877 に答える