tox命令在windows中引发异常

2024-06-16 14:24:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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

当我运行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')

如何解决我的问题


Tags: inpytoxpackageslocallineusersappdata
1条回答
网友
1楼 · 发布于 2024-06-16 14:24:26

我没有简单的解决方案,只有一个如何隔离问题以及如何自己解决问题的指南

在你的tox.ini文件中有很多事情正在进行。特别是在check环境中,您运行4个命令,此外,它还继承了泛型testenv

根据你的喜好更改订单,但我会先

  • 注释掉泛型testenv,因为它似乎没有必要使checkenv工作,因此可以避免副作用,例如passenv = *
  • 注释掉checkenv中的最后三个命令,只运行第一个命令,然后添加第二个命令,依此类推,直到找到有问题的命令

错误消息表明其中一个命令需要一个目录,但被传递到python解释器的路径

通过查看您的tox.ini,我无法立即看到问题所在,因此有关如何调试问题的说明,请参见上文

相关问题 更多 >