python安装数据库时报错 No module named 'mysql.connector'

 不多说,直接上干货!

 

复制代码

C:\Users\lenovo>pip install mysql-connector-python-rf==2.1.3
Collecting mysql-connector-python-rf==2.1.3
  Downloading mysql-connector-python-rf-2.1.3.tar.gz (271kB)
    100% |████████████████████████████████| 276kB 222kB/s
Building wheels for collected packages: mysql-connector-python-rf
  Running setup.py bdist_wheel for mysql-connector-python-rf ... done
  Stored in directory: C:\Users\lenovo\AppData\Local\pip\Cache\wheels\c3\c9\9e\926eae62d46c2f6f7b985165d6791e1a34e1a3a54ac38cda5c
Successfully built mysql-connector-python-rf
Installing collected packages: mysql-connector-python-rf
Successfully installed mysql-connector-python-rf-2.1.3

C:\Users\lenovo>python
Python 2.7.13 |Anaconda custom (64-bit)| (default, Sep 19 2017, 08:25:59) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

复制代码

 

 

 

 

 

  同时,去这个网址里https://www.lfd.uci.edu/~gohlke/pythonlibs/  把这几个都拿过来

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  进入,pip install  ***就好了

 

 

 

 

 

要在编译器里下 不是在cmd里下

pycharm的当前解释器和环境变量的解释器是同一个吗??

https://blog.csdn.net/qiannianguji01/article/details/50397046

把你当前的那个mysql文件夹名重命名一下。就是ceshi.py所在的这个,不要叫mysql

 

alt+f12   pip install mysql.connector

 pip install mysql.connector 已经试过了

 

目录改了

pip install mysql-connector-python-rf==X.X.X

X.X.X为python版本号