Seite 1 von 1

No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 04:24
von xiuk
Ich bin nach folgender Anleitung (http://www.nerdydork.com/django-dev-env ... charm.html) vorgegangen und habe versucht mit virtualenv eine unabhängige pythong / Django Installation zu erstellen. problem dabei ist, dass ich bei der installation von "mysql_python" folgende erromeldung bekomme.

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Folgende Ansätze habe ich bereits versucht:
Ich hab nun schon versucht die .profile zu ergänzen um "export PATH=/usr/local/mysql/bin:$PATH"
ich hab die installation von mysql_python mit pip und easy_install, mit und ohne virtualenv versucht.
der SQL server läuft und ich kann zB mit Sequel Pro darauf zugreifen.

Umgebung:
Mac OSX Lion
Python 2.7

Hat vielleicht noch jemand eine Idee, was ich noch probieren könnte, um das Ding endlich zum laufen zu bekommen? Würd mich freuen!

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 08:27
von deets
Du schreibst "ich hab die installation von mysql_python mit pip und easy_install, mit und ohne virtualenv versucht."

Was ist denn dabei rum gekommen, was war die Ausgabe auf der Kommandozeile?

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 13:12
von xiuk
sorry, war schon etwas spät gestern :)

Code: Alles auswählen

MacBook-Pro:bin thomas$ easy_install MySQL-python
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /var/folders/hm/0gr7nggd7131955r8yqjxf600000gn/T/easy_install-TUbkwq/MySQL-python-1.2.3/egg-dist-tmp-lhRBiu
sh: mysql_config: command not found
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install", line 8, in <module>
    load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1712, in main
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 1716, in <lambda>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 211, in run
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 446, in easy_install
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 476, in install_item
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 655, in install_eggs
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 930, in build_and_install
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 919, in run_setup
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 62, in run_setup
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 105, in run
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/sandbox.py", line 64, in <lambda>
  File "setup.py", line 15, in <module>
  File "/var/folders/hm/0gr7nggd7131955r8yqjxf600000gn/T/easy_install-TUbkwq/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
  File "/var/folders/hm/0gr7nggd7131955r8yqjxf600000gn/T/easy_install-TUbkwq/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
EnvironmentError: mysql_config not found

pip install MySQL-python

Code: Alles auswählen

MacBook-Pro:bin thomas$ pip install MySQL-python
Downloading/unpacking MySQL-python
Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 948, in prepare_files
    location = req_to_install.build_location(self.build_dir, not self.is_download)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 150, in build_location
    _make_build_dir(build_dir)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 1192, in _make_build_dir
    os.makedirs(build_dir)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/mysql-5.5.19-osx10.6-x86_64/bin/build'

Storing complete log in /Users/thomas/.pip/pip.log
MacBook-Pro:bin thomas$ sudo pip install MySQL-python
Password:
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/usr/local/mysql-5.5.19-osx10.6-x86_64/bin/build/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/usr/local/mysql-5.5.19-osx10.6-x86_64/bin/build/MySQL-python/setup.py", line 15, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found
und im der virtualenv genau die selben outputs.

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 13:29
von BlackJack
@xiuk: Offensichtlich kann ``mysql_config`` nicht gefunden werden. Also vorher installieren.

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 13:39
von xiuk
mysql ist installiert und läuft einwandfrei. ich kann per sequel Pro auf die DB zugreifen und hab in in der ~/.profile folgendes hinzugefügt:

Code: Alles auswählen

export PATH=/usr/local/mysql/bin:$PATH

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 13:54
von Hyperion
xiuk hat geschrieben:mysql ist installiert und läuft einwandfrei.
`mysql` ist aber ungleich `mysql_config`. Ich habe nur mal kurz gegoogelt, aber sofort Postings gefunden, nachdem dieses Tool nicht notwendiger Weise Bestandteil einer MySQL-Installation ist.

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 14:18
von deets
@xiuk

Er findet mysql_config aber nunmal nicht. Hast du das vorher mal ausprobiert, ob das in der shell geht?

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 14:40
von xiuk
ja das file ist das und ich kann es auch aufmachen. ich bin jetzt nach dem tutorial vorgegangen (http://blog.infoentropy.com/MySQL-pytho ... _not_found) und hab die "site.cfg" geändert, das package manuell gezogen entpackt.
nun gibt er mir einen anderen error:

error: command 'gcc-4.2' failed with exit status 1

das hatte ich zuletzt als xcode noch nicht installiert war. kann das sein, weil ich in der .bash_profile was geändert habe?

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 15:07
von deets
Seufz. Der erzaehlt doch bestimmt noch deutlich mehr, oder?

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 15:30
von xiuk
sry.

Code: Alles auswählen

MacBook-Pro:mySQL-python-1.2.3 thomas$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql//include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.6-intel-2.7/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch x86_64
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from _mysql.c:36:
/usr/local/mysql//include/my_config.h:329:1: warning: "SIZEOF_SIZE_T" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:9,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:43:1: warning: this is the location of the previous definition
In file included from _mysql.c:36:
/usr/local/mysql//include/my_config.h:422:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:887:1: warning: this is the location of the previous definition
error: command 'gcc-4.2' failed with exit status 1

Re: No module named MySQLdb

Verfasst: Dienstag 13. Dezember 2011, 15:59
von deets
Na, da wird doch ganz offensichtlich snow-leopard als SDK (10.6) versucht - obwohl du wahrscheinlich nur SDK 10.7 hast.

Du kannst also mal schauen, ob da jemand schonmal Probleme hatte, MYSQL oder generell Python-Extensions unter Lion zu bauen. Es gibt auch so eine Umgebungsvariable, die man setzen kann - hab die gerade nicht parat.

Aber schau mal, ob du da nicht was findest mit Python, Extension, Lion + Probleme.