在虚拟环境之外,它运行正常。但是在虚拟环境中,不会导入MySQL Python连接器。我正在研究Raspberry Pi。以下显示了我提到的内容。我该怎么做才能解决它?
=============================================== ============================
虚拟evn之外的pi@raspberrypi:~/webapp3 $ python3 vsearch_web.py
* Running on http://127.0.0.1:5000/
127.0.0.1 - - [15/Apr/2017 15:29:57] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [15/Apr/2017 15:30:17] "POST /search HTTP/1.1" 200 -
127.0.0.1 - - [15/Apr/2017 15:30:30] "GET /viewlog HTTP/1.1" 200 -
=============================================== ==========================
虚拟环境中的pi@raspberrypi:~/webapp3 $ source venv/bin/activate
(venv)pi@raspberrypi:~/webapp3 $ python3 vsearch_web.py
Traceback (most recent call last):
File "vsearch_web.py",
line 3,
in <module> from DBcm import UseDatabase File
"/home/pi/webapp3/DBcm.py",
line 1, in <module> import
mysql.connector
ImportError: No module named 'mysql'
答案 0 :(得分:0)
该模块尚未安装在虚拟环境中。激活环境并运行:
pip3 install mysqlclient