错误 No Module named “PyMySQL"视窗 10 [英] Error No Module named "PyMySQL" Windows 10

查看:68
本文介绍了错误 No Module named “PyMySQL"视窗 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试 pymysql 时遇到问题.

i have problem to try pymysql.

  1. 我的电脑使用的是 Windows 10
  2. 使用 python 3.5
  3. 我已经通过 pip install pymsql 安装了 pymysql 并且成功,没有错误.我已经检查了 pip list 并获得了 PyMySQL (0.7.9)
  1. my computer is using windows 10
  2. use python 3.5
  3. i have installed pymysql via pip install pymsql and success, no error. i have checked with pip list and get PyMySQL (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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆