简体   繁体   English

在 Ubuntu 15.04 上使用 Python 3.5 的 `virtualenv`

[英]`virtualenv` with Python 3.5 on Ubuntu 15.04

I've never used virtualenv , I'm working on Ubuntu 15.04 (remotely via ssh), and I've been told I can't make any changes to system the Pythons.我从未使用过virtualenv ,我正在使用 Ubuntu 15.04(通过 ssh 远程),并且有人告诉我我无法对 Python 系统进行任何更改。 Ubuntu 15.04 comes with Pythons 2.7 and 3.4.3, but I want Python 3.5 in my virtualenv . Ubuntu 15.04 带有 Python 2.7 和 3.4.3,但我希望在我的virtualenv Python 3.5。 I've tried virtualenv -p python3.5 my_env and it gives The executable python3.5 (from --python=python3.5) does not exist , which I take to mean that it's complaining about the system not having Python 3.5.我试过virtualenv -p python3.5 my_env并且它给出了The executable python3.5 (from --python=python3.5) does not exist ,我认为这意味着它在抱怨系统没有 Python 3.5。 So, is it impossible to create a virtualenv with Python 3.5, if the system does not already have Python 3.5?那么,如果系统还没有 Python 3.5,那么用 Python 3.5 创建一个virtualenv是不可能的吗?

You can just install the latest version of python.您可以安装最新版本的python。 You can also download and install the different versions in your user's home dir.您还可以在用户的​​主目录中下载并安装不同的版本。

In case you are planning to have multiple versions installed manually.如果您计划手动安装多个版本。 This is from the offical python README file.这是来自官方 python README 文件。

Installing multiple versions安装多个版本

On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version.在 Unix 和 Mac 系统上,如果您打算使用相同的安装前缀(配置脚本的 --prefix 参数)安装多个版本的 Python,您必须注意您的主要 python 可执行文件不会被不同版本的安装覆盖。 All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side.使用“make altinstall”安装的所有文件和目录都包含主要和次要版本,因此可以并排存在。 "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. “make install”还创建了 ${prefix}/bin/python3,它指的是 ${prefix}/bin/pythonX.Y。 If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version.如果您打算使用相同的前缀安装多个版本,您必须决定哪个版本(如果有)是您的“主要”版本。 Install that version using "make install".使用“make install”安装该版本。 Install all other versions using "make altinstall".使用“make altinstall”安装所有其他版本。

For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.例如,如果您想安装 Python 2.5、2.6 和 3.0,其中 2.6 是主要版本,您将在 2.6 构建目录中执行“make install”,并在其他目录中执行“make altinstall”。

Once done that you can continue using the virtual environment for python using the python version of your choice.完成后,您可以使用您选择的 python 版本继续使用 python 的虚拟环境。

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

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