[Django] #28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env file (TypeError: environment can only contain strings)

13 views
Skip to first unread message

Django

unread,
May 4, 2017, 4:32:08 PM5/4/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul | Owner: nobody
Mestemaker |
Type: Bug | Status: new
Component: Core | Version: 1.11
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
We have a .env file with a SECRET_KEY defined as follows
SECRET_KEY="SECRETKEYHERE"

This causes a failure with Django 1.11. The workarounds are:
1) Downgrade to Django 1.10
2) Remove the quotation marks and just have SECRET_KEY=SECRETKEYHERE

This appears to only be a problem on Windows and does not repro on
Mac/Linux.

{{{
(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>pip
install django==1.10 --upgrade
Collecting django==1.10
Downloading Django-1.10-py2.py3-none-any.whl (6.8MB)
100% |################################| 6.8MB 124kB/s
Installing collected packages: django
Found existing installation: Django 1.11
Uninstalling Django-1.11:
Successfully uninstalled Django-1.11
Successfully installed django-1.10

(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>python
manage.py runserver
Performing system checks...

RUNNING IN DEVELOPMENT MODE. ADDING STATIC FILE DIRECTORIES TO SERVE
System check identified no issues (0 silenced).
May 04, 2017 - 12:46:16
Django version 1.10, using settings 'dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>pip
install --upgrade django
Collecting django
Using cached Django-1.11-py2.py3-none-any.whl
Requirement already up-to-date: pytz in
c:\development\python\python2712\virtualenvs\tmadashboard\lib\site-
packages (from django)
Installing collected packages: django
Found existing installation: Django 1.10
Uninstalling Django-1.10:
Successfully uninstalled Django-1.10
Successfully installed django-1.11

(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>python
manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\__init__.py", line 363, in
execute_from_command_line
utility.execute()
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\commands\runserver.py", line 62, in
execute
super(Command, self).execute(*args, **options)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\commands\runserver.py", line 101, in
handle
self.run(**options)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\core\management\commands\runserver.py", line 110, in
run
autoreload.main(self.inner_run, None, options)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\utils\autoreload.py", line 332, in main
reloader(wrapped_main_func, args, kwargs)
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\utils\autoreload.py", line 303, in python_reloader
exit_code = restart_with_reloader()
File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib
\site-packages\django\utils\autoreload.py", line 289, in
restart_with_reloader
exit_code = subprocess.call(args, env=new_environ)
File "c:\development\python\python2712\Lib\subprocess.py", line 523, in
call
return Popen(*popenargs, **kwargs).wait()
File "c:\development\python\python2712\Lib\subprocess.py", line 711, in
__init__
errread, errwrite)
File "c:\development\python\python2712\Lib\subprocess.py", line 959, in
_execute_child
startupinfo)
TypeError: environment can only contain strings
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28174>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 4, 2017, 6:46:13 PM5/4/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Could you please
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#bisecting-a-regression bisect] to determine the Django commit
where the behavior changed? Please also provide steps to reproduce the
issue and explain why Django is at fault.

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:1>

Django

unread,
May 6, 2017, 3:17:08 PM5/6/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: nobody
Type: Bug | Status: closed

Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:2>

Django

unread,
Jul 11, 2017, 11:58:00 PM7/11/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: nobody
Type: Bug | Status: new

Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Rogaski):

* status: closed => new
* resolution: needsinfo =>


--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:3>

Django

unread,
Jul 11, 2017, 11:58:25 PM7/11/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: assigned

Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Rogaski):

* owner: nobody => Mark Rogaski
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:4>

Django

unread,
Jul 12, 2017, 12:02:15 AM7/12/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Rogaski):

This appears to have been introduced with this change.

https://github.com/django/django/commit/f6671c5d784e744f18bbc9e06dc4fcdb9e10065b
#diff-46e69f287173eef41fcbfeba05501954

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:5>

Django

unread,
Jul 12, 2017, 1:30:30 AM7/12/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Rogaski):

PR submitted.

https://github.com/django/django/pull/8737

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:6>

Django

unread,
Jul 12, 2017, 1:34:28 AM7/12/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Rogaski):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:7>

Django

unread,
Jul 12, 2017, 9:56:16 AM7/12/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* severity: Normal => Release blocker


--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:8>

Django

unread,
Jul 13, 2017, 1:41:03 PM7/13/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: closed

Component: Core (Management | Version: 1.11
commands) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"fc6b90bdb7a9531e988245942f79518308616b7b" fc6b90b]:
{{{
#!CommitTicketReference repository=""
revision="fc6b90bdb7a9531e988245942f79518308616b7b"
[1.11.x] Fixed #28174 -- Fixed crash in runserver's autoreload with Python
2 on Windows with non-str environment variables.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:9>

Django

unread,
Jul 13, 2017, 4:25:45 PM7/13/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: closed
Component: Core (Management | Version: 1.11
commands) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"37b2602c895139ff5a44626ed8469c681c438fe4" 37b2602c]:
{{{
#!CommitTicketReference repository=""
revision="37b2602c895139ff5a44626ed8469c681c438fe4"
Refs #28174 -- Added 1.11.4 release note for Python 2 runserver autoreload
fix.

Forwardport of fc6b90bdb7a9531e988245942f79518308616b7b from stable/1.11.x
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:10>

Django

unread,
Jul 15, 2017, 8:57:46 AM7/15/17
to django-...@googlegroups.com
#28174: Cannot run `manage.py runserver` on Windows with quotation mark in .env
file (TypeError: environment can only contain strings)
-------------------------------------+-------------------------------------
Reporter: Paul Mestemaker | Owner: Mark
| Rogaski
Type: Bug | Status: closed
Component: Core (Management | Version: 1.11
commands) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d9ef8ffb5854c9a5fd81f18b3e383accafd6d7ff" d9ef8ff]:
{{{
#!CommitTicketReference repository=""
revision="d9ef8ffb5854c9a5fd81f18b3e383accafd6d7ff"
[1.11.x] Refs #28174 -- Fixed autoreload test crash on Python 2/non-ASCII
path.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28174#comment:11>

Reply all
Reply to author
Forward
0 new messages