创建个人的虚拟环境

50 篇文章 8 订阅
4 篇文章 0 订阅

创建个人虚拟环境 virtualenv


[hilqiqi0@LINUX data]$ sudo mkdir hilqiqi0
[hilqiqi0@LINUX data]$ sudo chown -R hilqiqi0 hilqiqi0/
[hilqiqi0@LINUX data]$ cd hilqiqi0/
[hilqiqi0@LINUX hilqiqi0]$ ls
[hilqiqi0@LINUX hilqiqi0]$ virtualenv venv --python=/usr/local/python3/bin/python
Running virtualenv with interpreter /usr/local/python3/bin/python
Using base prefix '/usr/local/python3'
New python executable in /data/hilqiqi0/venv/bin/python
Installing setuptools, pip, wheel...done.
[hilqiqi0@LINUX hilqiqi0]$ ls
venv
[hilqiqi0@LINUX hilqiqi0]$ source venv/bin/activate
(venv) [hilqiqi0@LINUX hilqiqi0]$ pip

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user
                              configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times
                              (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5
                              times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
                              (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any
                              HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key
                              and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip
                              is available for download. Implied with --no-index.
  --no-color                  Suppress colored output
(venv) [hilqiqi0@LINUX hilqiqi0]$ pip list
Package    Version
---------- -------
pip        19.1.1
setuptools 41.0.1
wheel      0.33.1
(venv) [hilqiqi0@LINUX hilqiqi0]$ pip install schedule
Collecting schedule
  Using cached https://files.pythonhosted.org/packages/57/22/3a709462eb02412bd1145f6e53604f36bba191e3e4e397bea4a718fec38c/schedule-0.6.0-py2.py3-none-any.whl
Installing collected packages: schedule
Successfully installed schedule-0.6.0
(venv) [hilqiqi0@LINUX hilqiqi0]$ vim ~/.bashrc
(venv) [hilqiqi0@LINUX hilqiqi0]$ 

  • 设置个人启动环境,激活虚拟环境。最后一行加上 source /data/hilqiqi0/venv/bin/activate
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
source /data/hilqiqi0/venv/bin/activate

  • 退出环境
(venv) [hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$ deactivate
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$
  • 删除环境
    把文件夹删除了
(venv) [hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$ deactivate
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz ~]$ cd /data/hilqiqi0
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz hilqiqi0]$ ls
venv
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz hilqiqi0]$ rm -rf *
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz hilqiqi0]$ ls
[hilqiqi0@izbp1a3rsiacm6nu3bfnyuz hilqiqi0]$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值