Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#19238 closed Bug (invalid) 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


I installed django using python3, but by default uses python.

$ startproject foo
$ cd foo/
$ ./ startapp bar
Traceback (most recent call last):
  File "./", line 8, in <module>
    from import execute_from_command_line
ImportError: No module named
$ sed -i -e 's/env python/env python3/'
$ ./ startapp bar

Change History (2)

comment:1 Changed 8 years ago by Claude Paroz

Resolution: invalid
Status: newclosed

When you are running ./, 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 ...). 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.

comment:2 Changed 8 years ago by Aymeric Augustin

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 — 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.

Last edited 8 years ago by Aymeric Augustin (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top