RuntimeError: Cannot locate a COMSPEC environment variable... with os.popen on Windows

Issue #359 on hold
Cosimo Lupo created an issue

The distutils uses os.popen, which seems to require the %COMSPEC% environment variable to be set, else it raises a runtime error (see traceback below).

If I use passenv = COMSPEC in my tox.ini, then it works fine. The value of the variable on my system is the default C:\Windows\system32\cmd.exe.



py27 runtests: commands[2] | python test
running pytest
running egg_info
writing top-level names to src/python\compreffor.egg-info\top_level.txt
writing dependency_links to src/python\compreffor.egg-info\dependency_links.txt
writing src/python\compreffor.egg-info\PKG-INFO
reading manifest file 'src/python\compreffor.egg-info\SOURCES.txt'
reading manifest template ''
writing manifest file 'src/python\compreffor.egg-info\SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "", line 168, in <module>
  File "C:\Python27-mingwpy\Lib\distutils\", line 151, in setup
  File "C:\Python27-mingwpy\Lib\distutils\", line 953, in run_commands
  File "C:\Python27-mingwpy\Lib\distutils\", line 972, in run_command
  File "build\bdist.win32\egg\", line 85, in run
  File "C:\UsersLocal\cosimo.lupo\Documents\GitHub\compreffor\.tox\py27\lib\site-packages\setuptools\command\", line 111, in with_project_on_sys_path
    with self.project_on_sys_path():
  File "C:\Python27-mingwpy\Lib\", line 17, in __enter__
  File "C:\UsersLocal\cosimo.lupo\Documents\GitHub\compreffor\.tox\py27\lib\site-packages\setuptools\command\", line 139, in project_on_sys_path
  File "C:\Python27-mingwpy\Lib\distutils\", line 326, in run_command
  File "C:\Python27-mingwpy\Lib\distutils\", line 972, in run_command
  File "C:\UsersLocal\cosimo.lupo\Documents\GitHub\compreffor\.tox\py27\lib\site-packages\setuptools\command\", line 68, in run
  File "C:\Python27-mingwpy\Lib\distutils\command\", line 306, in run
  File "C:\Python27-mingwpy\Lib\distutils\", line 1004, in new_compiler
    return klass(None, dry_run, force)
  File "C:\Python27-mingwpy\Lib\distutils\", line 306, in __init__
    CygwinCCompiler.__init__ (self, verbose, dry_run, force)
  File "C:\Python27-mingwpy\Lib\distutils\", line 107, in __init__
  File "C:\Python27-mingwpy\Lib\distutils\", line 420, in get_versions
    out = os.popen(gcc_exe + ' -dumpversion','r')
RuntimeError: Cannot locate a COMSPEC environment variable to use as the shell
ERROR: InvocationError: 'C:\\UsersLocal\\cosimo.lupo\\Documents\\GitHub\\compreffor\\.tox\\py27\\Scripts\\python.EXE test'

Comments (2)

  1. Log in to comment