简体   繁体   English

mysql-python的问题

[英]issues with mysql-python

I installed django using following commands 我使用以下命令安装了django

cd Django-1.4.1
sudo python setup.py install
cd
mkdir testing
cd testing
django-admin.py
django-admin.py startproject demo
cd demo
python manage.py runserver

and Msql-python using 和Msql-python使用

pip install MySQL-python
sudo apt-get install python-pip
pip install MySQL-python

and still getting the error 仍然出现错误

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

See as Mike johnson said first check MySQLdb is really installed in your system or not 就像Mike johnson所说的那样,首先检查您的系统中是否确实安装了MySQLdb

if not then use 如果没有,那么使用

sudo apt-get install python-mysqldb

make sure it should installed properly 确保应正确安装

or you can use another alternative like easy_install 或者您可以使用另一种替代方法,例如easy_install

I tried to reproduce that problem on my Debian box and: 我试图在我的Debian盒子上重现该问题,并:

  1. Navigated to /usr/lib/pymodules/python2.6 导航到/usr/lib/pymodules/python2.6
  2. Ran a command: chmod go-rx MySQLdb 运行命令:chmod go-rx MySQLdb
  3. On the other console, did: 在另一个控制台上,执行以下操作:

    import MySQLdb 导入MySQLdb
    Traceback (most recent call last): 追溯(最近一次通话):
    File "", line 1, in 文件“”,第1行,位于
    ImportError: No module named MySQLdb ImportError:没有名为MySQLdb的模块

I suppose it might be something with rights management on your system (I had this issue on some RHEL server just a week ago). 我想这可能与您系统上的权限管理有关(一周前,我在某些RHEL服务器上遇到了此问题)。

What you might want to do (if it's not Debian): 您可能想做的事情(如果不是Debian):
1. Login as root. 1.以root用户身份登录。 2. Type: 2.输入:

# find / -name "MySQLdb"
  1. Navigate to directory that find finds (in my case it was /usr/lib/pymodules/python2.6). 导航到找到的目录(在我的情况下是/usr/lib/pymodules/python2.6)。
  2. Type: 类型:

    chmod -R go+rx MySQLdb chmod -R go + rx MySQLdb

  3. Test on not-elevated console if importing MySQLdb from Python and regular user context works. 在未提升的控制台上测试是否可以从Python导入MySQLdb和常规用户上下文。

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

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