Trying to run manage that requires MySQLdb

Background information:

1. I am new to UNIX, Python/Django and PyCharm (which I downloaded as evaluation).

2. As many other falks I exoeriences a great pain in trying to install MySQLdb (Python <-> MYSQL) under Mac OS X. But I managed to make it work.

3. The key for #2 above turned out to be (at least in my case since it seems that almost each and every person experience different problems with MySQLdb on Macs) the loading of libmysqlclient.16.dylib - a dynamic lib required for MySQLdb to work.

4. To take care of #3 above I do (using terminal):

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

After that MySQLdb like a charm on Mac OS X

The question I have - how do I expose /usr/local/mysql/lib/ to PyCharm environment? I tried to use Run->Edit Configurations dialog box where there is a place to specify environmental variables. But so far I failed. As a result it's really inconvenient to work with MYSQL from within PyCharm. Any suggestions?

See below a stack trace (PyCharm) when I try to run something that requires MySQLdb

Best regards,

Serge

/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/serge/PycharmProjects/Naviquan/manage.py inspectdb
Traceback (most recent call last):
  File "/Users/serge/PycharmProjects/Naviquan/manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/inspectdb.py", line 5, in <module>
    from django.db import connections, DEFAULT_DB_ALIAS
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 77, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/serge/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib
  Referenced from: /Users/serge/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so
  Reason: image not found

1 comment
Comment actions Permalink

Hello Sergey,

Please see http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x

for information on configuring environment variables on MacOS X.

Background information:

1. I am new to UNIX, Python/Django and PyCharm (which I downloaded as

evaluation).

2. As many other falks I exoeriences a great pain in trying to install

MySQLdb (Python <-> MYSQL) under Mac OS X. But I managed to make it

work.

3. The key for #2 above turned out to be (at least in my case since it

seems that almost each and every person experience different problems

with MySQLdb on Macs) the loading of libmysqlclient.16.dylib - a

dynamic lib required for MySQLdb to work.

4. To take care of #3 above I do (using terminal): export

DYLD_LIBRARY_PATH=/usr/local/mysql/lib/ After that MySQLdb like a

charm on Mac OS X

The question I have - how do I expose /usr/local/mysql/lib/ to PyCharm

environment? I tried to use Run->Edit Configurations dialog box where

there is a place to specify environmental variables. But so far I

failed. As a result it's really inconvenient to work with MYSQL from

within PyCharm. Any suggestions?

See below a stack trace (PyCharm) when I try to run something that

requires MySQLdb

Best regards,

Serge

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

/Users/serge/PycharmProjects/Naviquan/manage.py inspectdb

Traceback (most recent call last):

File "/Users/serge/PycharmProjects/Naviquan/manage.py", line 11, in

<module>

execute_manager(settings)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/core/management/__init__.py", line 438, in

execute_manager

utility.execute()

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/core/management/__init__.py", line 379, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/core/management/__init__.py", line 261, in

fetch_command

klass = load_command_class(app_name, subcommand)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/core/management/__init__.py", line 67, in

load_command_class

module = import_module('%s.management.commands.%s' % (app_name,

name))

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/utils/importlib.py", line 35, in import_module

__import__(name)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/core/management/commands/inspectdb.py", line 5, in

<module>

from django.db import connections, DEFAULT_DB_ALIAS

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/db/__init__.py", line 77, in <module>

connection = connections[DEFAULT_DB_ALIAS]

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/db/utils.py", line 92, in __getitem__

backend = load_backend(db['ENGINE'])

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/db/utils.py", line 33, in load_backend

return import_module('.base', backend_name)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/utils/importlib.py", line 35, in import_module

__import__(name)

File

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-

packages/django/db/backends/mysql/base.py", line 14, in <module>

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb

module:

dlopen(/Users/serge/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-

intel.egg-tmp/_mysql.so, 2): Library not loaded:

libmysqlclient.16.dylib

Referenced from:

/Users/serge/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.e

gg-tmp/_mysql.so

Reason: image not found

---

Original message URL:

http://devnet.jetbrains.net/message/5292163#5292163

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Please sign in to leave a comment.