如果 OS Python 版本是 3.5,如何设置 pipenv Python 3.6 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49794432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setup a pipenv Python 3.6 project if OS Python version is 3.5?
提问by Sun Bear
My Ubuntu 16.04.03 is installed with Python 3.5.2. How do I setup pipenv to use Python 3.6 when my system does not have python 3.6?
我的 Ubuntu 16.04.03 安装了 Python 3.5.2。当我的系统没有 python 3.6 时,如何设置 pipenv 以使用 Python 3.6?
$ pipenv --python 3.6
Warning: Python 3.6 was not found on your system…
You can specify specific versions of Python with:
$ pipenv --python path/to/python
回答by pawamoy
Either manually write the version you need in your Pipfile:
在 Pipfile 中手动编写您需要的版本:
[requires]
python_version = "3.6"
Or install it on your system. But I guess you willneed the version to be installed if you plan to actually run pipenv install
.
或者在您的系统上安装它。但我猜你会需要的版本进行安装,如果你打算实际运行pipenv install
。
I would suggest to use pyenv
: https://github.com/pyenv/pyenv.
我建议使用pyenv
:https: //github.com/pyenv/pyenv。
Follow the installation instructions, then installing Python 3.6 is just a matter of
按照安装说明,然后安装 Python 3.6 只是一个问题
pyenv install 3.6.3
Then you can set the order of preference with
然后你可以设置优先顺序
pyenv global system 3.6.3
Besides, if pyenv
is available, pipenv
will automatically use it to install the required version. From pipenv
README:
此外,如果pyenv
可用,pipenv
将自动使用它来安装所需的版本。从pipenv
自述文件:
Automatically install required Pythons, if pyenv is available.
如果 pyenv 可用,则自动安装所需的 Python。
回答by andreielizaga
On MacOS, I have also used pyenvto manage python versions, similar to @pawamoy's suggestion.
在 MacOS 上,我也使用pyenv来管理 python 版本,类似于@pawamoy 的建议。
After installation I executed pipenv shell
with the --python
option pointing to the directory of the specific pyenv
version. This will automatically generate a Pipfile
with python_version = "3.6"
.
安装后,我pipenv shell
使用--python
指向特定pyenv
版本目录的选项执行。这将自动生成一个Pipfile
with python_version = "3.6"
。
? pipenv --python /Users/<Your User>/.pyenv/versions/3.6.3/bin/python3.6 shell
回答by Roushan
Install python 3.6 reference
安装python 3.6参考
Ubuntu 14.04 and 16.04 If you are using Ubuntu 14.04 or 16.04, you can use Felix Krull's deadsnakes PPA at https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa:
Ubuntu 14.04 和 16.04 如果您使用的是 Ubuntu 14.04 或 16.04,您可以在https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa使用 Felix Krull 的 deadsnakes PPA :
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
Alternatively, you can use J Fernyhough's PPA at https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6:
或者,您可以在https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6使用 J Fernyhough 的 PPA :
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
Ubuntu 16.10 and 17.04
If you are using Ubuntu 16.10 or 17.04, then Python 3.6 is in the universe repository, so you can just run:
如果您使用的是 Ubuntu 16.10 或 17.04,则 Python 3.6 位于 Universe 存储库中,因此您只需运行:
sudo apt-get update
sudo apt-get install python3.6
Then create specific version python env
然后创建特定版本的python env
virtualenv -p python3.6 python36venv
回答by Adnan Murtaza
Install 'pyenv' package by using brew install pyenv
(if you don't have it).
使用安装 'pyenv' 包brew install pyenv
(如果你没有)。
Install python 3.6 using pyenv install 3.6
安装 python 3.6 使用 pyenv install 3.6
Export new installed python version to PATH
将新安装的 python 版本导出到 PATH
export PATH=${PYENV_PYTHON_VERSIONS_HOME}/3.6/bin
export PATH=${PYENV_PYTHON_VERSIONS_HOME}/3.6/bin
Now in 'Piplock' specify the same version.
现在在“Piplock”中指定相同的版本。
[requires]
python_version = "3.6"
[requires]
python_version = "3.6"
Finally, run pipenv install --dev
.
最后,运行pipenv install --dev
。
回答by Yunier Rojas
I don't think you can do a virtualenv of a Python version you don't have. What you can do is one of these options:
我不认为你可以做一个你没有的 Python 版本的 virtualenv。您可以做的是以下选项之一: