1

I installed Python 3.4.2 and Django 1.7.1 but I can import django only from Python 2.7.

I installed the latest version of Python from the official website and I installed Django with:

pip install Django==1.7.1

Bill T
  • 31
  • 3
  • How did you install Django? – Simeon Visser Nov 14 '14 at 20:03
  • What version of Python does your installed version of `pip` use? – Damian Yerrick Nov 14 '14 at 20:09
  • I used pip install Django==1.7.1, option 1 proposed in https://www.djangoproject.com/download/ – Bill T Nov 14 '14 at 20:10
  • You need to use a pip installed to your python3.4.2. Try `python3 -m pip`. If it can't find `pip`, you need to install it for that version of Python. Or just try `pip3` instead of `pip`. – Ned Deily Nov 14 '14 at 20:13
  • @tepples, Ned Deily: Thanks! My installed version of pip uses Python 2.7. Now, with pip3 install Django==1.7.1 and it works! (ref: http://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-python-versions ) – Bill T Nov 14 '14 at 20:14

2 Answers2

1

you need to use the python 3.4.2 interpreter and it's own pip...you should look into virtualenv.

docs for virtualenv:

http://virtualenv.readthedocs.org/en/latest/virtualenv.html

or you could run a command like this:

$ /path/to/python3/lib/site-packages/pip install Django==1.7.1

EDIT: While my answer is possible, it is not recommended, rather you should use the following command like suggested by the other answer:

$ pip<VERSION> install Django==1.7.1

since pip has supported this apparently since version 0.8

iLoveTux
  • 3,552
  • 23
  • 31
  • I already looked at this possibility, and there is a great answer here: http://stackoverflow.com/questions/23256054/install-django1-7-with-python-3-4-using-virtualenv , but it is not what I was looking for. – Bill T Nov 14 '14 at 20:24
  • I am glad that you found your answer. I would still suggest using virtualenv (IMO It's just a better way), but if you found what you are looking for then that is what matters. I would suggest waiting just a bit longer to post questions here since you have demonstrated some skill level of searching the site, It is best to use existing answers when possible and only post new questions if they don't exist here. – iLoveTux Nov 14 '14 at 20:34
1

Problem solved by installing Django with:

pip3 install Django==1.7.1

The command pip seems to manage packages for one version of Python (2.7 here) and we should use it with Python version number to install package for a specific Python version. Explanation here

Community
  • 1
  • 1
Bill T
  • 31
  • 3