简体   繁体   English

tox 命令在 windows 中引发异常

[英]tox command raise exception in windows

I have tox.ini like below in windows我在 windows 中有如下的 tox.ini

[testenv:bootstrap]
deps =
    jinja2
    matrix
    tox
skip_install = true
commands =
    python ci/bootstrap.py --no-env
passenv =
    *
; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist

[tox]
envlist =
    clean,
    check,
    docs,
    py38,
    report
ignore_basepython_conflict = true

[testenv]
setenv =
    PYTHONPATH={toxinidir}/tests
    PYTHONUNBUFFERED=yes
passenv =
    *
usedevelop = false
deps =
    pytest
    pytest-travis-fold
    pytest-cov
commands =
    {posargs:pytest --cov --cov-report=term-missing -vv tests}

[testenv:check]
deps =
    docutils
    check-manifest
    flake8
    readme-renderer
    pygments
    isort
skip_install = true
commands =
    python setup.py check --strict --metadata --restructuredtext
    check-manifest {toxinidir}
    flake8
    isort --verbose --check-only --diff --filter-files .

[testenv:docs]
usedevelop = true
deps =
    -r{toxinidir}/docs/requirements.txt
commands =
    sphinx-build {posargs:-E} -b doctest docs dist/docs
    sphinx-build {posargs:-E} -b html docs dist/docs
    sphinx-build -b linkcheck docs dist/docs

[testenv:report]
deps =
    coverage
skip_install = true
commands =
    coverage report
    coverage html

[testenv:clean]
commands = coverage erase
skip_install = true
deps =
    coverage

When I run tox -e check I see below exception and traceback当我运行tox -e check时,我看到下面的异常和回溯

    PS D:\Projects\ControlProject\ControlProject> tox -e check
check create: D:\Projects\ControlProject\ControlProject\.tox\check
check installdeps: docutils, check-manifest, flake8, readme-renderer, pygments, isort
_______________________________________________________________________________________________________________________________________ summary _______________________________________________________________________________________________________________________________________
  check: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\py\_error.py", line 66, in checked_call
    return func(*args, **kwargs)
OSError: [Errno 22] Invalid argument: 'C:\\Users\\ssoroosh\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\tox.exe\__main__.py", line 7, in <module>
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\session\__init__.py", line 44, in cmdline
    main(args)
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\session\__init__.py", line 69, in main
    exit_code = session.runcommand()
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\session\__init__.py", line 197, in runcommand
    return self.subcommand_test()
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\session\__init__.py", line 225, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\session\commands\run\sequential.py", line 11, in run_sequential
    venv.finishvenv()
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\venv.py", line 661, in finishvenv
    self.finish()
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\venv.py", line 318, in finish
    live_config = self._getliveconfig()
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\venv.py", line 289, in _getliveconfig
    base_resolved_python_sha256 = getdigest(base_resolved_python_path)
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\tox\venv.py", line 669, in getdigest
    return path.computehash("sha256")
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\py\_path\local.py", line 240, in computehash
    f = self.open('rb')
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\py\_path\local.py", line 369, in open
    return py.error.checked_call(open, self.strpath, mode)
  File "C:\Users\ssoroosh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\py\_error.py", line 86, in checked_call
    raise cls("%s%r" % (func.__name__, args))
py.error.ENOTDIR: [Not a directory]: open('C:\\Users\\ssoroosh\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe', 'rb')

How to resolve my problem?如何解决我的问题?

I have no simple solution but a guideline how to isolate the problem and how to fix it yourself.我没有简单的解决方案,而是提供如何隔离问题以及如何自己解决问题的指南。

In your tox.ini file a lot is going on.在您的tox.ini文件中发生了很多事情。 Especially in your check env you run 4 commands, and additionally it inherits from the generic testenv .特别是在您的check env 中,您运行 4 个命令,此外它还继承自通用testenv

Change the order to your liking, but I would first...根据您的喜好更改顺序,但我会先...

  • comment out the generic testenv as it does not seem to be necessary for the check env to work, and so you can avoid side effects, maybe caused eg by passenv = *注释掉通用testenv ,因为check env 似乎不需要工作,因此您可以避免副作用,例如可能由passenv = *
  • comment out the last three commands in your check env and only run the first, then add the second and so on until you find the problematic command注释掉check环境中的最后三个命令,只运行第一个,然后添加第二个,依此类推,直到找到有问题的命令

The error message suggests one of the commands expects a directory, but was passed the path to the python interpreter.错误消息表明其中一个命令需要一个目录,但已将路径传递给 python 解释器。

From looking at your tox.ini I cannot see where the problem is at once, thus the instruction on how to debug the problem, see above.通过查看您的tox.ini ,我无法立即看到问题出在哪里,因此有关如何调试问题的说明,请参见上文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM