創建個人的虛擬環境


創建個人虛擬環境 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章