pyenv: 没有名为 `virtualenv' 的命令

55
我正在跟随一个关于在Ubuntu 20.04上安装torch的教程,其中一行需要设置pyenv,类似于Python的virtualenv,这样我就可以运行多个Python版本。这有点不必要,但这是一个学习过程,也是一个学习另一个新工具的好机会,以后可能会用到。所以,在成功设置pyenv之后,这个命令失败了。
sam@sam:~/torch$ pyenv virtualenv 3.8.2 torch
pyenv: no such command `virtualenv'

为了涵盖我的基础知识,我已经安装了virtualenv,如下所示

sam@sam:~/torch$ virtualenv
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--app-data APP_DATA] [--clear-app-data] [--discovery {builtin}] [-p py] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed]
                [--activators comma_sep_list] [--clear] [--system-site-packages] [--symlinks | --copies] [--download | --no-download] [--extra-search-dir d [d ...]] [--progress version] [--retrying version] [--urllib3 version]
                [--pep517 version] [--colorama version] [--CacheControl version] [--certifi version] [--requests version] [--contextlib2 version] [--appdirs version] [--chardet version] [--pytoml version] [--html5lib version]
                [--lockfile version] [--six version] [--webencodings version] [--pyparsing version] [--setuptools version] [--packaging version] [--wheel version] [--ipaddr version] [--idna version] [--pip version] [--distro version]
                [--pkg_resources version] [--distlib version] [--msgpack version] [--no-progress] [--no-retrying] [--no-urllib3] [--no-pep517] [--no-colorama] [--no-CacheControl] [--no-certifi] [--no-requests] [--no-contextlib2]
                [--no-appdirs] [--no-chardet] [--no-pytoml] [--no-html5lib] [--no-lockfile] [--no-six] [--no-webencodings] [--no-pyparsing] [--no-setuptools] [--no-packaging] [--no-wheel] [--no-ipaddr] [--no-idna] [--no-pip] [--no-distro]
                [--no-pkg_resources] [--no-distlib] [--no-msgpack] [--symlink-app-data] [--prompt prompt] [-h]
                dest
virtualenv: error: the following arguments are required: dest

并且按照此处所示安装了pyenv

sam@sam:~/torch$ pyenv
pyenv 1.2.19-1-gece59ca8
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
commands    List all available pyenv commands
exec        Run an executable with the selected Python version
global      Set or show the global Python version(s)
help        Display help for a command
hooks       List hook scripts for a given pyenv command
init        Configure the shell environment for pyenv
install     Install a Python version using python-build
local       Set or show the local application-specific Python version(s)
prefix      Display prefix for a Python version
rehash      Rehash pyenv shims (run this after installing executables)
root        Display the root directory where versions and shims are kept
shell       Set or show the shell-specific Python version
shims       List existing pyenv shims
uninstall   Uninstall a specific Python version
--version   Display the version of pyenv
version     Show the current Python version(s) and its origin
version-file   Detect the file that sets the current pyenv version
version-name   Show the current Python version
version-origin   Explain how the current Python version is set
versions    List all Python versions available to pyenv
whence      List all Python versions that contain the given executable
which       Display the full path to an executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme

11
本教程假设您已安装了pyenv-virtualenv。仅当您安装了pyenv-virtualenv时,pyenv virtualenv命令才会生效。请参考https://github.com/pyenv/pyenv-virtualenv。 - Vishal Singh
看起来你安装了 pyenv 但忘记安装另一个依赖项 pyenv-virtualenv。投票关闭此问题,因为它是微不足道的。第三方软件包 virtualenv 是不必要和无关紧要的。 - tripleee
你可以在这里使用我的解决方案:https://stackoverflow.com/a/62534632/12075605 - Mostafa
3
运行 pip install pyenv-virtualenv 给我返回了以下错误:`ERROR: Could not find a version that satisfies the requirement pyenv-virtualenv ERROR: No matching distribution found for pyenv-virtualenv`使用 Python 3.8.7 和 pip 21.0.1。 - SimpleJ
1个回答

69

这个问题已经在你的评论下面的讨论中被提及,但是你需要使用pyenv-virtualenv。

如何下载:https://github.com/pyenv/pyenv-virtualenv

在Mac上,可以通过homebrew轻松安装:brew install pyenv-virtualenv


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接