#19238 closed Bug (invalid)
manage.py does not use python3
Reported by: | Cybjit | Owned by: | nobody |
---|---|---|---|
Component: | Python 3 | Version: | 1.5-alpha-1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I installed django using python3, but by default manage.py uses python.
$ django-admin.py startproject foo $ cd foo/ $ ./manage.py startapp bar Traceback (most recent call last): File "./manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management $ sed -i -e 's/env python/env python3/' manage.py $ ./manage.py startapp bar $
Change History (2)
comment:1 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 12 years ago
It appears that python
invokes Python 2 and python3
invokes Python 3 on your system.
You have the following options:
- 1) use a virtualenv created with Python 3 — the Python binary copied in the virtualenv will be used,
- 2) make Python 3 the default Python, so that
env python
invokes Python 3 (see your OS' manual), - 3) use
python3 manage.py
— if you want a non-default Python, you have to say it.
Changing the sheebang like you suggest is incorrect because it's OS-dependent. It could fix your problem on your development system but break it on your production environment.
Selecting the correct Python binary is the job of env
. Options 1) and 2) above take advantage of that.
Note:
See TracTickets
for help on using tickets.
When you are running
./manage.py
, you implicitely call the current default python executable. If you'd like to force a non-default python, specify it on the command line (python3 manage.py ...
). And more generally, I would suggest to make use of virtualenv, where you can specify the default python version for each of your projects separately.