简体   繁体   English

pyenv-virtualenv如何指定使用.file使用的virtualenv?

[英]Pyenv - virtualenv how to specify virtualenv used by using .file?

如何使用.file指定pyenv-virtual env,以便当我cd到目录时自动获得正确的pyenv和正确的virtualenv。

Pyenv envaroment can be managed using .python-version files. 可以使用.python-version文件管理.python-version

First, install required python version using the command below example. 首先,使用以下示例命令安装所需的python版本。 You can find list of all available python versions with pyenv install --list in your terminal. 您可以在终端中使用pyenv install --list找到所有可用python版本的列表。

Pyenv install 3.5.2

Next create pyenv virtual environment using following command. 接下来,使用以下命令创建pyenv虚拟环境。 my-virtual-env-3.5.2 is the name of your environment my-virtual-env-3.5.2是您的环境的名称

pyenv virtualenv 3.5.2 my-virtual-env-3.5.2

Next go to directory where you want to use this virtualenv and create .python-version file 接下来转到要使用此virtualenv的目录并创建.python-version文件

Edit your envaroment name and path to this file. 编辑您的环境名称和此文件的路径。

3.5.2/envs/my-virtual-env-3.5.2

In case you are not sure about the path and name of your environment you can list your environments running > 如果您不确定环境的路径和名称,可以列出正在运行的环境>

pyenv versions

In your terminal 在您的终端

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

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