网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

python建立venv虚拟环境的方法

这篇文章将为大家详细讲解有关python建立venv虚拟环境的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

站在用户的角度思考问题,与客户深入沟通,找到滨江网站设计与滨江网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计制作、成都网站设计、企业官网、英文网站、手机端网站、网站推广、申请域名、网络空间、企业邮箱。业务覆盖滨江地区。

创建虚拟环境

在当前目录创建虚拟环境:

$ python -m venv .1

下面是”venv”的详细使用参数:

usage: venv [-h] [--system-site-packages] [--symlinks] [--clear]
            [--upgrade] [--without-pip] ENV_DIR [ENV_DIR ...]

Creates virtual Python environments in one or more target directories.

positional arguments:
  ENV_DIR             A directory to create the environment in.

optional arguments:
  -h, --help             show this help message and exit
  --system-site-packages Give access to the global site-packages dir to the                         
  virtual environment.
  --symlinks             Try to use symlinks rather than copies, when symlinks
                         are not the default for the platform.
  --copies               Try to use copies rather than symlinks, even when
                         symlinks are the default for the platform.
  --clear                Delete the environment directory if it already exists.                        
                         If not specified and the directory exists, an error is
                         raised.
  --upgrade              Upgrade the environment directory to use this version                        
                         of Python, assuming Python has been upgraded in-place.
  --without-pip          Skips installing or upgrading pip in the virtual
                         environment (pip is bootstrapped by default)

激活虚拟环境

在Posix标准平台下:

$ source /bin/activate

在Windows cmd下:

C:> /Scripts/activate.bat

在Windows PowerShell下:

PS C:> /Scripts/Activate.ps1

测试虚拟环境

激活虚拟环境后,在命令行会提示当前虚拟环境的名称,就表示激活成功了。

在当前虚拟环境中安装numpy:

$ pip install numpy

当前安装的numpy包与系统中的不会冲突,下面进行测试:

$ python
>>> import numpy
>>> print(numpy)

如果输出了numpy的包路径就表示一切正常。


关于python建立venv虚拟环境的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


本文名称:python建立venv虚拟环境的方法
浏览地址:http://bjjierui.cn/article/jhojcs.html

其他资讯