0

So I've: chmod +x manage.pyso I can just ./manage.py when needed, but it defaults to python 2.7, but I want it to use python 3.4 I also have installed. I know I could just use python3 manage.pybut I want to know if there's a way to use the shortcut without calling the default python.

I'm on Ubuntu, not in a virtual environment, and don't want to make py3 the default as I know py2 is required by some core operations in the system, so I'd appreciate a localized solution.

Thanks!

EDIT: Days after this question I started to experience problems at the system level due to messing around with the default python 2 of the system and python 3, and solved the conflict issues by using a virtualenv. So if you're in my same position, just use a virtualenv(even if you don't like the concept, like me) it saves you future headaches.

Anthony O.
  • 15
  • 1
  • 5

2 Answers2

1

The easiest way to fix it is to change the first line in your ./manage.py to

#!/usr/bin/env python3

However it is much better to use virtualenv to manage all your python environments.

Yossi
  • 11,778
  • 2
  • 53
  • 66
  • I read that changing the hashbang could cause problems in production as it's a os-dependent. https://code.djangoproject.com/ticket/19238 – Anthony O. Mar 30 '15 at 07:30
  • 1
    You must be kidding. Why ask a question if you already googled the answer? – Yossi Mar 30 '15 at 07:36
  • 1
    I wanted to make sure there was no other way. And apparently I'll have to change the hashbang, as I figured I can manage the potential problems in a production environment . Anyways, thanks for the input, I guess I'll mark your post as the answer for my scenario. – Anthony O. Mar 30 '15 at 07:40
0

Also you can point desired version of python:

python3 manage.py ...

...or even:

/usr/bin/python3 manage.py ....
Ihor Pomaranskyy
  • 5,437
  • 34
  • 37