简体   繁体   English

在Ubuntu 12.04 LTS上安装Botched Python(无法导入MySQL)

[英]Botched Python install on Ubuntu 12.04 LTS (can't import MySQL)

I am a beginner programmer trying to learn python. 我是一个尝试学习python的初学者程序员。 I made the smart move to Ubuntu, but being unfamiliar with this OS environment I believe I botched the install of Python. 我明智地迁移到了Ubuntu,但是由于不熟悉此OS环境,所以我相信我不赞成安装Python。

I have installed VIM and MySQL. 我已经安装了VIM和MySQL。 They are both installed correctly. 它们都已正确安装。 VIM works correctly with Python, but MySQL does not. VIM在Python上可以正常使用,但MySQL不能。

When I try to import MySQL into python I get: 当我尝试将MySQL导入python时,我得到:

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb

I believe that my PATH setup is wrong with Python. 我相信我的PATH设置对于Python是错误的。 I have tried to uninstall and reinstall. 我试图卸载并重新安装。 Someone said it might be that I have Python 2.7.5 installed when I need 2.7.3 on Ubuntu 12.04. 有人说可能是我在Ubuntu 12.04上需要2.7.3时安装了Python 2.7.5。

Here is my sys.path 这是我的sys.path

>>> import sys
>>> print sys.path
['', '/home/allen/lib/python', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages'

I wish I could fix this on my own, I have been searching online with no success. 我希望自己能解决这个问题,但我一直在网上搜索,但没有成功。 Thanks in advance for any help. 在此先感谢您的帮助。 It's very much appreciated. 非常感谢。

您还需要安装mySql-Python,因为需要导入python绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM