Shouldn't manage.py call python3 instead of python?

182 views
Skip to first unread message

Bobby Mozumder

unread,
Apr 6, 2018, 5:07:35 PM4/6/18
to Django developers (Contributions to Django itself)
The header of manage.py has: #!/usr/bin/env python

Shoudn’t it be: #!/usr/bin/env python3

Since 2.0 is now only Python3. Both my Mac OS & FreeBSD environments have Python 3.5+ as “python3". (I’m not sure about Linux or other environments).

Is that a bug I need to file?

-bobby

Josh Smeaton

unread,
Apr 6, 2018, 6:35:50 PM4/6/18
to Django developers (Contributions to Django itself)
I think you're right and PEP394 is the relevant text: https://www.python.org/dev/peps/pep-0394/

TL;DR

For now, python should refer to python2 and python3 should be used to refer to python 3.

Tim Graham

unread,
Apr 6, 2018, 8:30:01 PM4/6/18
to Django developers (Contributions to Django itself)
It was tried in https://code.djangoproject.com/ticket/27878 but it caused problems, particularly on Windows.

Bobby Mozumder

unread,
Apr 8, 2018, 3:19:16 AM4/8/18
to Django developers (Contributions to Django itself)
Is it OK to reopen that ticket?

The problem is that python2 and python3 need to coexist in most systems, and you can’t just rename python3 to python.

-bobby

-- 
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7cdf48bb-ab0b-449d-8f33-a4c6d7777369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Forbes

unread,
Apr 8, 2018, 8:28:18 AM4/8/18
to django-d...@googlegroups.com
This only seems to be an issue when you are using the base system interpreter to run manage.py. installing Django and other dependencies there is not recommended for a variety of reasons, and this isn't a problem when using a virtualenv, it doesn't seem like there is much to fix IMO.


Bobby Mozumder

unread,
Apr 8, 2018, 10:00:49 AM4/8/18
to Django developers (Contributions to Django itself)
I never really liked the idea of using VirtualEnv or HomeBrew over the default installation in Mac OS.  (FreeBSD has the same naming issues).  

Having beginners use VirtualEnv or HomeBrew always struck me as a huge obstacle to getting a beginners Django developer's environment operational, as well as being a huge pain-in-the-ass of always setting VirtualEnvs for each shell.  So, I personally don’t use them anymore, and just use the base system now.

I wish there was a process of running Django out-of-the-box from a default Mac OS install.

-bobby

Tom Forbes

unread,
Apr 8, 2018, 11:03:00 AM4/8/18
to django-d...@googlegroups.com

It may be an obstacle but I believe it’s better than having them nuke their base systems by accident by installing a package that conflicts with their base system. This isn’t such a huge issue on MacOS but on Linux it is and I’ve seen it happen a few times. Not to mention the issue of multiple conflicting dependencies across projects - all in all it’s really not a recommended and we should not look to make it easier IMO.

People have different setups and whatever works, works, but things like pipenv are maturing rapidly and solve the convenience issue you describe. I personally use virtualenvwrapper which is really simple to set up and displays the current virtual environment in the prompt, and makes it really easy to switch between them/create new ones.

Tom

Collin Anderson

unread,
Apr 9, 2018, 3:53:58 PM4/9/18
to django-d...@googlegroups.com
I personally just edit my manage.py to change it from python to python3. Maybe we could just document that?

(Or would it work to use os.path.basename(sys.executable) ?)

-bobby

-bobby

To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsub...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

Adam Johnson

unread,
Apr 9, 2018, 3:58:38 PM4/9/18
to django-d...@googlegroups.com
(Or would it work to use os.path.basename(sys.executable) ?)

The shebang is interpreted by the OS so this is before python even starts :)

-bobby

-bobby

To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam

Collin Anderson

unread,
Apr 9, 2018, 6:35:39 PM4/9/18
to django-d...@googlegroups.com
I'm thinking something like #!/usr/bin/env {{ os.path.basename(sys.executable) }} when running startproject. (Though on windows I that would be #!/usr/bin/env python.exe - not sure if that would work or not)

Adam Johnson

unread,
Apr 10, 2018, 4:28:12 AM4/10/18
to django-d...@googlegroups.com

Tim Allen

unread,
Apr 10, 2018, 7:28:33 AM4/10/18
to Django developers (Contributions to Django itself)
Since `django-admin startproject my_project` is created on the fly from templates, couldn't we dynamically create the `manage.py` executable based on some system introspection and an agreed upon priority?

Regards,

Tim

Florian Apolloner

unread,
Apr 10, 2018, 11:43:21 AM4/10/18
to Django developers (Contributions to Django itself)


On Tuesday, April 10, 2018 at 1:28:33 PM UTC+2, Tim Allen wrote:
Since `django-admin startproject my_project` is created on the fly from templates, couldn't we dynamically create the `manage.py` executable based on some system introspection and an agreed upon priority

Wouldn't that result in something along the lines of "works on my system" and breaks elsewhere? after all manage.py is committed into git more often than not.

Aymeric Augustin

unread,
Apr 10, 2018, 3:46:49 PM4/10/18
to django-d...@googlegroups.com

... which directs us to the correct solution: setting PYTHONPATH and DJANGO_SETTINGS_MODULE correctly and using django-admin instead of manage.py. 

pip / setuptools rewrites the shebang line appropriately when it installs the django-admin script. (I'm not sure how this happens exactly.)

My point is — there's no perfect solution. At best we can aim for a less imperfect solution than the status quo.

-- 
Aymeric.

Bobby Mozumder

unread,
Apr 10, 2018, 10:02:31 PM4/10/18
to Django developers (Contributions to Django itself)
In any case you’re going to see a lot of Django 2.0 developers on Mac OS hit this problem when they install to default Python or use standard Python install convention where Python 3.5 is installed as “python3".

-bobby

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.

Josh Smeaton

unread,
Apr 10, 2018, 10:17:22 PM4/10/18
to Django developers (Contributions to Django itself)
As a datapoint, I've seen roughly 1 person per week in #django IRC confused about specific startup exceptions due to them using python 2 rather than python 3 on Django >= 2.0. Unsure how many of these are due to the shebang. That said, it looks like there are no good solutions other than maybe ensuring our docs always show the form python3 manage.py <command> rather than ./manage.py <command>.

Collin Anderson

unread,
Apr 11, 2018, 8:47:07 AM4/11/18
to django-d...@googlegroups.com
but python3 manage.py <command> doesn't work on windows, right?

To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

Matthew Pava

unread,
Apr 11, 2018, 9:14:54 AM4/11/18
to django-d...@googlegroups.com

Right.  I just use python manage.py…

I just checked python3 manage.py and it doesn’t work.


For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.

Reply all
Reply to author
Forward
0 new messages