2

I installed a virtualbox with xubuntu-16.04.2-desktop on windows 10. when I create an env running a mezzanine app, I get this error:

Traceback (most recent call last):
File "manage.py", line 7, in <module>
from mezzanine.utils.conf import real_project_name
ImportError: No module named 'mezzanine'

the same when I try to import modules:

(test) mauri@bison:~$ python -c "import django"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'django'

the problem seems to be the PYTHONPATh, not set correctly. If i set it manually, everything works fine.

(test) mauri@bison:~$ export 
PYTHONPATH="/home/mauri/envs/test/lib/python3.5/site-packages/"
(test) mauri@bison:~$ python -c "import django"
(test) mauri@bison:~$ env
XDG_VTNR=7
LC_PAPER=cs_CZ.UTF-8
LC_ADDRESS=cs_CZ.UTF-8
 XDG_SESSION_ID=c1
....

any idea why the PYTHONPATH is not set automatically when I create envs?

thank you so much, and sorry if I miss anything in the explaination, I m pretty new in this field.

2
  • 4
    The PYTHONPATH environment doesn't get set when you activate a virtual environment. That isn't how it works. Run python and do import sys; print(sys.path), the site-packages directory should be automatically added. Commented Jul 3, 2017 at 11:13
  • this is the result (test) mauri@bison:~$ python -c "import sys; print(sys.path)" ['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages'] Commented Jul 3, 2017 at 12:01

1 Answer 1

1

Check your bash* if you have any alias overriding the python setup. You can easily check with the command alias from bash:

$ alias
alias ll='ls -alh'
alias ls='ls -G'
...
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that was the problem. Removed the alias, everything now works perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.