Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named winreg: windows python2.7 #1315

Closed
asottile opened this issue May 23, 2019 · 9 comments · Fixed by #1316
Closed

No module named winreg: windows python2.7 #1315

asottile opened this issue May 23, 2019 · 9 comments · Fixed by #1316
Labels
bug:normal affects many people or has quite an impact pr-merged

Comments

@asottile
Copy link
Contributor

$ tox -e py37
GLOB sdist-make: C:\Users\Anthony\AppData\Local\Temp\x\tox\aspy.yaml\setup.py
py37 create: C:\Users\Anthony\AppData\Local\Temp\x\tox\aspy.yaml\.tox\py37
___________________________________ summary ___________________________________
  py37: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "C:\Users\Anthony\AppData\Local\Temp\x\tox\aspy.yaml\venv\Scripts\tox-script.py", line 11, in <module>
    load_entry_point('tox', 'console_scripts', 'tox')()
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\session\__init__.py",line 44, in cmdline
    main(args)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\session\__init__.py",line 68, in main
    exit_code = session.runcommand()
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\session\__init__.py",line 192, in runcommand
    return self.subcommand_test()
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\session\__init__.py",line 220, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\session\commands\run\sequential.py", line 9, in run_sequential
    if venv.setupenv():
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\venv.py", line 595, in setupenv
    status = self.update(action=action)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\venv.py", line 253, in update
    self.hook.tox_testenv_create(action=action, venv=self)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 81, in get_result
    _reraise(*ex)  # noqa
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\venv.py", line 665, in tox_testenv_create
    config_interpreter = venv.getsupportedinterpreter()
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\venv.py", line 294, in getsupportedinterpreter
    return self.envconfig.getsupportedinterpreter()
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\config\__init__.py", line 953, in getsupportedinterpreter
    info = self.config.interpreters.get_info(envconfig=self)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\interpreters\__init__.py", line 32, in get_info
    executable = self.get_executable(envconfig)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\interpreters\__init__.py", line 26, in get_executable
    exe = self.hook.tox_get_python_executable(envconfig=envconfig)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 208, in _multicall
    return outcome.get_result()
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 81, in get_result
    _reraise(*ex)  # noqa
  File "c:\users\anthony\appdata\local\temp\x\tox\aspy.yaml\venv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\interpreters\windows\__init__.py", line 21, in tox_get_python_executable
    py_exe = locate_via_pep514(spec)
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\interpreters\windows\__init__.py", line 45, in locate_via_pep514
    from . import pep514
  File "c:\users\anthony\appdata\local\temp\x\tox\src\tox\interpreters\windows\pep514.py", line 8, in <module>
    import winreg
ImportError: No module named winreg

Seems this module is not present in python2.7:

$ C:/Python27/python.exe -c 'import winreg'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named winreg
$ C:/Python37/python.exe -c 'import winreg'
$
@asottile asottile added the bug:normal affects many people or has quite an impact label May 23, 2019
@gaborbernat
Copy link
Member

gaborbernat commented May 23, 2019

@asottile
Copy link
Contributor Author

yeah, working on a patch for it -- not sure what's going on with our CI though :S

@gaborbernat
Copy link
Member

for some reason 3.7 matches 2.7 during specification lookup...

@asottile
Copy link
Contributor Author

I can also reproduce the version incorrectness as well:

$ tox -e py27
GLOB sdist-make: C:\Users\Anthony\AppData\Local\Temp\x\tox\aspy.yaml\setup.py
py27 inst-nodeps: C:\Users\Anthony\AppData\Local\Temp\x\tox\aspy.yaml\.tox\.tmp\package\1\aspy.yaml-1.2.0.zip
py27 installed: aspy.yaml==1.2.0,atomicwrites==1.3.0,attrs==19.1.0,cfgv==1.6.0,colorama==0.4.1,coverage==4.5.3,entrypoints==0.3,flake8==3.7.7,identify==1.4.3,importlib-metadata==0.13,mccabe==0.6.1,more-itertools==7.0.0,nodeenv==1.3.3,pluggy==0.11.0,pre-commit==1.16.1,py==1.8.0,pycodestyle==2.5.0,pyflakes==2.1.1,pytest==4.5.0,PyYAML==5.1,six==1.12.0,toml==0.10.0,virtualenv==16.6.0,wcwidth==0.1.7,zipp==0.5.1
py27 run-test-pre: PYTHONHASHSEED='953'
py27 run-test: commands[0] | coverage erase
py27 run-test: commands[1] | coverage run -m pytest tests
============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
cachedir: aspy.yaml\.tox\py27\.pytest_cache
rootdir: C:\Users\Anthony\AppData\Local\Temp\x\tox, inifile: tox.ini, testpaths: tests
collected 3 items

tests\yaml_test.py ...                                                   [100%]

========================== 3 passed in 0.07 seconds ===========================
py27 run-test: commands[2] | coverage report --show-missing --fail-under 100
Name                    Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------
aspy\__init__.py            1      0      0      0   100%
aspy\yaml\__init__.py      20      0      0      0   100%
tests\__init__.py           0      0      0      0   100%
tests\yaml_test.py         14      0      0      0   100%
-------------------------------------------------------------------
TOTAL                      35      0      0      0   100%
py27 run-test: commands[3] | pre-commit install
pre-commit installed at .git\hooks\pre-commit
___________________________________ summary ___________________________________
  py27: commands succeeded
  congratulations :)

@gaborbernat
Copy link
Member

gaborbernat commented May 23, 2019

The https://github.com/tox-dev/tox/blob/master/src/tox/interpreters/py_spec.py#L31 spec matching looks ok though

GitHub
Command line driven CI frontend and development task automation tool - tox-dev/tox

@gaborbernat
Copy link
Member

If you run it with -vv py27 uses C:\hostedtoolcache\windows\Python\3.7.2\x86\python.exe

@asottile
Copy link
Contributor Author

this one is a bit rough to debug, seems output is gobbled somewhere

But with this patch:

     def satisfies(self, req):
+        import pprint
+        print('*' * 79)
+        pprint.pprint(vars(req))
+        pprint.pprint(vars(self))
+        print('*' * 79)
         if req.is_abs and self.is_abs and self.path != req.path:

I get this output:

*******************************************************************************
{'architecture': None,
 'args': None,
 'major': 2,
 'minor': 7,
 'name': 'python',
 'path': None}
{'architecture': 64,
 'args': None,
 'major': 2,
 'minor': 7,
 'name': u'python',
 'path': 'c:\\users\\anthony\\appdata\\local\\temp\\x\\tox\\aspy.yaml\\venv\\scripts\\python.exe'}
*******************************************************************************

which at least looks right 🤔

@asottile
Copy link
Contributor Author

gotta run to a meeting, I'll poke at this in a bit

@gaborbernat
Copy link
Member

found it #1317 ... 🤦‍♂

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact pr-merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants