我正在Ubuntu上使用木星笔记本。我是一个新手(编码和ubuntu),试图学习如何使用Python访问数据库。
有人能解释我的问题是什么吗?
这就是我经历的过程:
我以为我安装了PyMySQL。
我查过这个:
import pymysql得到了这个错误
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-3dee6b071588> in <module>()
----> 1 import pymysql.cursor
ImportError: No module named 'pymysql'我以为我没有安装它,就跑到终端机上:
sudo pip install PyMySQL得到了这个结果
目录‘/home/username/..cache/pip’或其父目录不属于当前用户,缓存轮已被禁用。检查该目录的权限和所有者。如果使用sudo执行pip,则可能需要sudo的-H标志。已经满足的需求:/usr/ PyMySQL /lib/python2.7/dist-packages中的
然后我跑了:
sudo -h pip install PyMySQL
install: missing destination file operand after 'PyMySQL'
Try 'install --help' for more information.发布于 2017-08-27 17:24:38
木星笔记本有某种形式的终端模拟器,您正在使用吗?如果它真的尝试使用ubuntu的终端。Ctrl+Alt+T是这样做的捷径。
然后,在安装pip之后,尝试这些命令中的任何一个来下载您版本的python的PyMySQL。
sudo apt-get install python-pip
sudo pip install PyMySQL
sudo pip2 install PyMySQL
sudo pip3 install PyMySQL 最后导入PyMySQL包。
import pymysql发布于 2017-08-27 17:32:23
在终点站我进入
sudo pip3 install PyMySQL收到了以下消息和响应。
目录‘/home/username/..cache/pip’或其父目录不属于当前用户,缓存轮已被禁用。检查该目录的权限和所有者。如果使用sudo执行pip,则可能需要sudo的-H标志。
Collecting PyMySQL
Downloading PyMySQL-0.7.11-py2.py3-none-any.whl (78kB)
100% |████████████████████████████████| 81kB 1.1MB/s
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.7.11在木星我跑了
import pymysql没有收到任何错误信息。好像起作用了。
https://stackoverflow.com/questions/45907400
复制相似问题