python type help copyright_Python virtualenv选择错误的库

博客主要介绍了Python虚拟环境(virtualenv)的使用。可创建隔离环境,无需访问全局站点包,最新版本默认禁用访问。文中展示了使用系统Python 2.7.6提供的virtualenv创建环境、安装包等操作,还提及引用Python 3.3.4解释器的方法及查看已安装包的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建隔离的环境,而无需访问全局站点包.要么有意启用/禁用该行为.最新版本默认禁用访问.

我假设您想要一个隔离的环境来测试Python 3.3.4.

下面我正在使用系统python 2.7.6提供的virtualenv

$virtualenv --version

1.11.2

$virtualenv

You must provide a DEST_DIR

Usage: virtualenv [OPTIONS] DEST_DIR

Options:

--version show program's version number and exit

-h, --help show this help message and exit

-v, --verbose Increase verbosity.

-q, --quiet Decrease verbosity.

-p PYTHON_EXE, --python=PYTHON_EXE

The Python interpreter to use, e.g.,

--python=python2.5 will use the python2.5 interpreter

to create the new environment. The default is the

interpreter that virtualenv was installed with

(/usr/bin/python)

--clear Clear out the non-root install and start from scratch.

--no-site-packages DEPRECATED. Retained only for backward compatibility.

Not having access to global site-packages is now the

default behavior.

--system-site-packages

Give the virtual environment access to the global

site-packages.

--always-copy Always copy files rather than symlinking.

--unzip-setuptools Unzip Setuptools when installing it.

--relocatable Make an EXISTING virtualenv environment relocatable.

This fixes up scripts and makes all .pth files

relative.

--no-setuptools Do not install setuptools (or pip) in the new

virtualenv.

--no-pip Do not install pip in the new virtualenv.

--extra-search-dir=DIR

Directory to look for setuptools/pip distributions in.

This option can be used multiple times.

--never-download DEPRECATED. Retained only for backward compatibility.

This option has no effect. Virtualenv never downloads

pip or setuptools.

--prompt=PROMPT Provides an alternative prompt prefix for this

environment.

--setuptools DEPRECATED. Retained only for backward compatibility.

This option has no effect.

--distribute DEPRECATED. Retained only for backward compatibility.

This option has no effect.

我创建一个virtualenv,转到目录并使用相对路径从此virtualenv内部寻址python解释器和pip.

$virtualenv --no-site-packages venv_pygments

New python executable in venv_pygments/bin/python

Installing setuptools, pip...done.

$cd venv_pygments/

$bin/pip install pygments

Downloading/unpacking pygments

Downloading Pygments-2.0.2-py2-none-any.whl (672kB): 672kB downloaded

Installing collected packages: pygments

Successfully installed pygments

Cleaning up...

$bin/python

Python 2.7.6 (default, Jun 22 2015, 17:58:13)

[GCC 4.8.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import pygments

>>> pygments.__version__

'2.0.2'

在创建您的virtualenv时,您需要继续使用该选项

–python=/usr/local/bin/python3

像已经提到的那样引用Python 3.3.4解释器.

最新的默认virtualenv通常仅安装了几个软件包.如果您拥有更多,则可以访问全局站点程序包.

$bin/pip freeze

Pygments==2.0.2

argparse==1.2.1

wsgiref==0.1.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值