Focus on IT Recommend

Home > django - How to use Python 3 (3.5) as the default interpreter in my virtual environment?

django - How to use Python 3 (3.5) as the default interpreter in my virtual environment?

I ran into problems when I installed Python 3.5 on Mac. I wanted to use Python 3.5 as the interpreter when I ran my Django development server. I got this issue when I tried it (I know I must install a virtualenv, read below):

$ python3 runserver
Traceback (most recent call last):
  File "", line 7, in <module>
    from mezzanine.utils.conf import real_project_name
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Mezzanine-4.0.1-py3.5.egg/mezzanine/utils/", line 7, in <module>
    from django.conf import global_settings as defaults
ImportError: No module named 'django'

The first was when I tried installing pip packages it installed by default on the Python 2.7 in my virtual environment:

pip install django==1.9rc2
Collecting django==1.9rc2
  Downloading Django-1.9rc2-py2.py3-none-any.whl (6.4MB)
    100% |████████████████████████████████| 6.4MB 66kB/s 
Installing collected packages: django
Successfully installed django-1.9rc2

I use Django so I tried also install a virtual environment for the first time. First I tried it with pip, but that didn't work.

So how do I setup so that my Python3.5 is the default usage when using Python interpreter and in my virtual environment? I can't figure this out or I have done something wrong in my process.


Thanks for the answer and comment. I tried with the both solutions and the same error persisted. See output below:

$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 Django/
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/", line 14, in <module>
    import shutil
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 10, in <module>
    import fnmatch
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 15, in <module>
    import functools
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/", line 21, in <module>
    from collections import namedtuple
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/", line 16, in <module>
    from reprlib import recursive_repr as _recursive_repr
  File "/Library/Python/2.7/site-packages/reprlib/", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

My virtualenv version: 13.1.2

Recommend:django - error in python virtual environment

 d/ This project was setup inside a cpanel server. But the current server I using is not a cpanel server. It is normal centos server. Can somebody help me to track down the issue. answer 1

python django python-3.x virtualenv
  this question
edited Dec 1 '15 at 13:44 asked Dec 1 '15 at 13:17 lol5433 136 16 1   try this when creating a new virtualenv $ virtualenv -p /usr/bin/python3.5 <path/to/new/virtualenv/> taken from… –  qasimalbaqali Dec 1 '15 at 13:20      @qasimalbaqali: I tried with that, check the output above in my question. –  lol5433 Dec 1 '15 at 13:32      Have you actually activate your virtualenv? Also what version of virtualenv are you using? –  Padraic Cunningham Dec 1 '15 at 13:34      @PadraicCunningham he is trying to create a virtualenv so he cannot actually activate it before creating a python 3.5 virtualenv. –  qasimalbaqali Dec 1 '15 at 13:36      @PadraicCunningham: Yes, It worked for Python 2.7. But then I tried again because I wanted Python 3.5 instead and now I can't even create a virtual environment. –  lol5433 Dec 1 '15 at 13:36  |  show more comments

2 Answers


Your error is related to a known virtualenv bug regarding python-future and mixing up the 2.7 and 3.x module paths, the solution is to downgrade virtualenv to a version < 12.04, 12.0.2 is suggested in the link.

  this answer
answered Dec 1 '15 at 13:41 Padraic Cunningham 116k 9 70 134      Worked like a charm, thank you Padraic! –  lol5433 Dec 1 '15 at 13:53      No prob, you're welcome –  Padraic Cunningham Dec 1 '15 at 13:53


Firstly, If you are going to use multiple versions of python,then you must use Virtual Env.Also then Create your virtualenv using the following command so that it uses python 3.5 as default environment :

          virtualenv -p python3 envname

and then install django in the virtualenv.after activating your virtualenv

  this answer
edited Dec 1 '15 at 13:29 answered Dec 1 '15 at 13:23 Allen Fernandes 571 3 15      Thank you for the answer, check my edit above. –  lol5433 Dec 1 '15 at 13:31


Recommend:django - How to use virtualenv in Python project

project when I run it, instead of it using the standard directories for installed Python libraries answer 1 Check out the example below, and also the virtualenv documentation. It's actually fairly straightforward if you follow the steps: v


------splitte line----------------------------