gpt4 book ai didi

python mysqldb导入错误

转载 作者:太空宇宙 更新时间:2023-11-03 17:01:31 24 4
gpt4 key购买 nike

在 ubuntu 上我已经安装了 mysql 但我仍然无法导入 mysql 数据库。以下是我遵循的步骤。任何人都可以指出我的解决方案吗(其他信息是 ubuntu 安装在虚拟盒子上希望不要紧)。Python 版本是 2.6.5

  root@rajeev-laptop:/opt/s/site# apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
python-mysqldb-dbg
The following NEW packages will be installed:
python-mysqldb
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/76.6kB of archives.
After this operation, 283kB of additional disk space will be used.
Selecting previously deselected package python-mysqldb.
(Reading database ... 151280 files and directories currently installed.)
Unpacking python-mysqldb (from .../python-mysqldb_1.2.2-10build1_i386.deb) ...
Setting up python-mysqldb (1.2.2-10build1) ...

Processing triggers for python-support ...
root@rajeev-laptop:/opt/s/site# python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
>>>

最佳答案

全部,

我通过以下方式解决了这个问题,在我的/etc/bash.bashrc 中,我将 pythonpath 导入为/opt/s/django 和我的站点所在的位置。当我从 pythonpath 中删除以下内容时,导入 MySQLdb 起作用了。希望这篇文章对某人有所帮助。

关于python mysqldb导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11433207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com