django 4.0.4 ./manage working, however when using the management command 'runserver', an error is returned

233 Views Asked by At

A peculiar thing is happening with my Django Manage script.

No changes have been made since yesterday, however 'runserver' stopped working, and returns:

ValueError: illegal environment variable name

If I run other management functions that script works fine, so I get no errors, unless I use the 'runserver'

If I run ./manage on it's own, I get the management command list:

Type 'manage.py help ' for help on a specific subcommand.

Available subcommands:

[auth] changepassword createsuperuser

[contenttypes] remove_stale_contenttypes

[django] check compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages makemigrations migrate sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver

[sessions] clearsessions

[staticfiles] collectstatic findstatic runserver


The trace :

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    main()
  File "./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 74, in execute
    super().execute(*args, **options)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 111, in handle
    self.run(**options)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 118, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/utils/autoreload.py", line 682, in run_with_reloader
    exit_code = restart_with_reloader()
  File "/home/troy/env/visulink/lib/python3.8/site-packages/django/utils/autoreload.py", line 274, in restart_with_reloader
    p = subprocess.run(args, env=new_environ, close_fds=False)
  File "/usr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1594, in _execute_child
    self._posix_spawn(args, executable, env, restore_signals,
  File "/usr/lib/python3.8/subprocess.py", line 1545, in _posix_spawn
    self.pid = os.posix_spawn(executable, args, env, **kwargs)
ValueError: illegal environment variable name

Additional test with new environment setup:

Fresh install of python3 virtualenv and pip install django==4.0.4 fails when using management command for runserver:

 ➜  env virtualenv test-django-4.0.4
created virtual environment CPython3.8.10.final.0-64 in 1627ms
  creator CPython3Posix(dest=/home/troy/env/test-django-4.0.4, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/troy/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
➜  env source test-django-4.0.4/bin/activate
(test-django-4.0.4) ➜  env cd ~/          
(test-django-4.0.4) ➜  ~ cd Websites/test 
(test-django-4.0.4) ➜  test pip install django==4.0.4
Collecting django==4.0.4
  Using cached Django-4.0.4-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
  Using cached asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
Collecting backports.zoneinfo; python_version < "3.9"
  Using cached backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
Installing collected packages: asgiref, sqlparse, backports.zoneinfo, django
Successfully installed asgiref-3.5.0 backports.zoneinfo-0.2.1 django-4.0.4 sqlparse-0.4.2
(test-django-4.0.4) ➜  test django-admin startproject testing
(test-django-4.0.4) ➜  test cd testing 
(test-django-4.0.4) ➜  testing ls
manage.py  testing
(test-django-4.0.4) ➜  testing ./manage.py runserver
Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    main()
  File "./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 74, in execute
    super().execute(*args, **options)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 111, in handle
    self.run(**options)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 118, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/utils/autoreload.py", line 682, in run_with_reloader
    exit_code = restart_with_reloader()
  File "/home/troy/env/test-django-4.0.4/lib/python3.8/site-packages/django/utils/autoreload.py", line 274, in restart_with_reloader
    p = subprocess.run(args, env=new_environ, close_fds=False)
  File "/usr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1594, in _execute_child
    self._posix_spawn(args, executable, env, restore_signals,
  File "/usr/lib/python3.8/subprocess.py", line 1545, in _posix_spawn
    self.pid = os.posix_spawn(executable, args, env, **kwargs)
ValueError: illegal environment variable name
(test-django-4.0.4) ➜  testing 


➜  django_test printenv
SSH_AUTH_SOCK=/tmp/ssh-mbetSVxkQkQg/agent.2775
SSH_AGENT_PID=2840
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=i3
COLORTERM=truecolor
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
DESKTOP_SESSION=i3
USER=troy
HOME=/home/troy
=
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_VTNR=2
XDG_SEAT=seat0
I3SOCK=/run/user/1000/i3/ipc-socket.2775
GTK_MODULES=gail:atk-bridge
XDG_DATA_DIRS=/usr/share/i3:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_CONFIG_DIRS=/etc/xdg/xdg-i3:/etc/xdg
XDG_SESSION_DESKTOP=i3
VTE_CJK_WIDTH=narrow
WINDOWPATH=2
QT_ACCESSIBILITY=1
VTE_VERSION=6003
LOGNAME=troy
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_ID=2
XDG_SESSION_TYPE=x11
SHELL=/usr/bin/zsh
USERNAME=troy
SHLVL=1
XAUTHORITY=/run/user/1000/gdm/Xauthority
PWD=/home/troy/Websites/test/django_test
XDG_SESSION_CLASS=user
GDMSESSION=i3
TERM=xterm-256color
DISPLAY=:0
OLDPWD=/home/troy/Websites/test
ZSH=/home/troy/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
_=/usr/bin/printenv
0

There are 0 best solutions below