【问题标题】:pytest wants to us incorrect python 3 versionpytest 想要我们不正确的 python 3 版本
【发布时间】:2016-08-23 01:19:39
【问题描述】:

pytest 出于某种原因正在寻找 python3.4。

$pytest
-bash: /usr/local/bin/pytest: /usr/local/opt/python3/bin/python3.4: bad interpreter: No such file or directory

我使用的是 OS X,我之前安装了 python3.4,但现在使用 python3.5 已经有一段时间了。 编辑:我可能升级不正确,这很可能导致了这个问题。

我使用brew 安装了 3.4 和 3.5。

$brew list python3
/usr/local/Cellar/python3/3.5.1/bin/2to3-3.5
...etc.
/usr/local/Cellar/python3/3.5.1/bin/python3.5
...etc.

我正在使用带有 python3.5 和 pip3 的虚拟环境。我有以下设置:

$echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python3.5
$ echo $VIRTUALENVWRAPPER_VIRTUALENV
/usr/local/bin/virtualenv-3.5

Python3 和 pip 工作正常:

$ which python
<blah>/.virtualenvs/<blah>/bin/python
$ python
Python 3.5.1 (default, Dec 26 2015, 18:08:53)
$ pip -V
pip 8.1.1 from /<blah>/.virtualenvs/<blah>/lib/python3.5/site-packages (python 3.5)

我在安装 pytest 时尝试了带有 pip 的--isolated 标志:

$ pip install -h
...
--isolated    Run pip in an isolated mode, ignoring environment variables and user configuration.

是这样的:

$ pip install --isolated pytest
Collecting pytest
  Using cached pytest-2.9.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): py>=1.4.29 in /<blah>/.virtualenvs/<blah>/lib/python3.5/site-packages (from pytest)
Installing collected packages: pytest
Successfully installed pytest-2.9.1

但 pytest 仍在寻找 python3.4。

python3.4 肯定有什么问题,不幸的是,pytest 安装正在接受它。

任何人都可以对此有所了解吗? 谢谢!

【问题讨论】:

    标签: python macos python-3.x pytest python-venv


    【解决方案1】:

    咳咳

    要运行 pytest,您可以使用:

    $py.test
    

    而不是

    $pytest
    

    pytest 可执行文件/usr/local/bin/pytest 已有一年多的历史,我假设是旧安装。

    ls -plah /usr/local/bin/pytest
    -rwxr-xr-x  1 root  admin   154B 15 Apr  2015 /usr/local/bin/pytest
    

    我删除了它并使用 pip 卸载并重新安装了 pytest。重新安装不会重新创建 /usr/local/bin/pytest。事后看来,如果 pip 确实将任何内容放在活动的 .virtualenv 目录之外,我会感到惊讶。

    总结:

    【讨论】:

    • pytest 是由旧版本的pylint 安装的可执行文件(通过logilab-common)。
    • 嗯。我们都时不时地做手掌。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-16
    • 2019-07-13
    • 1970-01-01
    • 2013-11-15
    • 2020-07-10
    • 1970-01-01
    • 2021-10-13
    相关资源
    最近更新 更多