问题描述
我在尝试 pymysql 时遇到问题.
i have problem to try pymysql.
- 我的电脑使用的是 Windows 10
- 使用 python 3.5
- 我已经通过
pip install pymsql
安装了 pymysql 并且成功,没有错误.我已经检查了pip list
并获得了PyMySQL (0.7.9)
- my computer is using windows 10
- use python 3.5
- i have installed pymysql via
pip install pymsql
and success, no error. i have checked withpip list
and getPyMySQL (0.7.9)
但是当我运行 import PyMySQL
时得到错误没有名为PyMySQL"的模块,问题出在哪里?
but when i run import PyMySQL
get error no module named "PyMySQL" where is the problem?
但是如果我尝试import pymysql
,我得到了错误:
but if i try import pymysql
, i got error :
Traceback (most recent call last):
File "pymysql1.py", line 1, in <module>
import pymysql
File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql\__init__.py", line 29, in <module>
from .err import (
File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql\err.py", line 1, in <module>
import struct
File "C:\python\struct.py", line 2, in <module>
pack('hhl', 1, 2, 3)
NameError: name 'pack' is not defined
推荐答案
step-1:使用命令卸载现有的pymysql
step-1 :Uninstall the existing pymysql by using the command
pip uninstall PyMySQL
step-2 : 使用命令pip3安装pymysql
step-2 : Install the pymysql by using the command pip3
pip3 install PyMySQL
第三步:导入pymysql
这应该有效.当我尝试使用命令 import PyMySQL
导入 pymysql 时,我在 Windows 8 中使用 python3.4 它没有用,但是在执行上述步骤后,我尝试了 import pymysql
然后就完美运行了.
This should work. I am using python3.4 in windows 8 when I tried to import pymysql using the command import PyMySQL
it didn't work, but after performing the above steps then I tried import pymysql
then it worked perfectly.
这篇关于错误 No Module named “PyMySQL"视窗 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!