Virtualenv + Django on OSX issue?

Hello everyone -

I've done a bit of googling, forums searching-etc to try and find a solution to this problem, but I can't seem to.  Hopefully I'm just doing something silly!

I have a pretty large and complex django project in a virtualenv that i've been working on for quite some time using a mix of different development environments.  I've started to play with pycharm and am very intrigued but have run into a strange issue.

If I use the virtualenv as my Project Interpretor, whenever I try to run this code from inside PyCharm I get the following error:

/Users/nick/envs/project/bin/python /Applications/ --client --port 52659 --file runserver --noreload 8000

PyDev console: using IPython

pydev debugger: starting

Connected to pydev debugger (build 117.200)

/Users/nick/envs/project/lib/python2.7/site-packages/pytz/ UserWarning: Module xmlrpclib was already imported from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.pyc, but /Users/nick/envs/project/lib/python2.7/site-packages is being added to sys.path

  from pkg_resources import resource_stream

/Users/nick/envs/projhect/lib/python2.7/site-packages/pytz/ UserWarning: Module SimpleXMLRPCServer was already imported from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/, but /Users/nick/envs/project/lib/python2.7/site-packages is being added to sys.path

  from pkg_resources import resource_stream

Error: cannot import name utils

Process finished with exit code 1

The "utils" package missing is a reference to django.db.utils (which does exist.)
I've tried upgrading to newer dev branches of ipython and also tried to just remove ipython from the virtualenv -- both were no luck.  Also, the above seems to also be implying that /System/Library/Frameworks... is being added as well?
Strangely enough, if I don't use the VirtualEnv (and I make sure that all my packages are installed in the system-wide lib directory) it does work with no problems.
Anybody seen this issue before?
Comment actions Permalink

Looks like a similar problem is tracked as in our issue tracker.

Comment actions Permalink

Hi Dmitry,

I saw that bug but I don't think its the same problem.  It looks like my site packages is in the virtualenv configuration.  I've attached a screenshot of all my paths.  The second to last path seems to be the site-packages of the virtualenv (called "trove").

Thanks again!

Comment actions Permalink

Interesting.  I got it to work.  This probably is because we have a very non-standard way of handling our file so we can deploy it across multiple environments.

For anybody else who runs into this issue:

We have a *and* a  The contains various box specific settings that typically shouldn't be checked in or is box specific (passwords, etc.)

In our we have at the very bottom:


    from local_settings import *

except ImportError:


Now inside, we had a few other imports that ultimately lead to a circular import.  Strangely though, this issue doesn't happen when I just run it from the CLI.  I wonder if the modules are loaded in a slightly different order in the CLI vs PyCharm....

Regardless, everything looks ok now.  Sorry for the noise!



Please sign in to leave a comment.