最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[记录]CentOS中安装和使用virtualenv

CentOS crifan 2708浏览 0评论

折腾:

[记录]CentOS服务器中为微信开发安装Flask服务器

期间,去用pip安装virtualenv,结果出错:

[已解决]CentOS中zsh: command not found: pip

然后再继续安装virtualenv:

jiandaoweixin pip install virtualenv
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.
Collecting virtualenv
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading virtualenv-15.0.3-py2.py3-none-any.whl (3.5MB)
    100% || 3.5MB 43kB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-15.0.3

看看命令:

 jiandaoweixin virtualenv –help
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 in the new virtualenv.
  –no-pip              Do not install pip in the new virtualenv.
  –no-wheel            Do not install wheel in the new virtualenv.
  –extra-search-dir=DIR
                        Directory to look for setuptools/pip distributions in.
                        This option can be used multiple times.
  –download            Download preinstalled packages from PyPI.
  –no-download, –never-download
                        Do not download preinstalled packages from PyPI.
  –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.
 jiandaoweixin

然后去安装:

 jiandaoweixin virtualenv jiandaoweixin
New python executable in /usr/share/nginx/html/jiandaoweixin/jiandaoweixin/bin/python
Installing setuptools, pip, wheel…done.
 jiandaoweixin ll
total 4.0K
drwxr-xr-x 5 root root 4.0K Aug 10 17:47 jiandaoweixin
 jiandaoweixin cd jiandaoweixin 
 jiandaoweixin ll
total 16K
drwxr-xr-x 2 root root 4.0K Aug 10 17:47 bin
drwxr-xr-x 2 root root 4.0K Aug 10 17:46 include
drwxr-xr-x 3 root root 4.0K Aug 10 17:46 lib
lrwxrwxrwx 1 root root    3 Aug 10 17:46 lib64 -> lib
-rw-r–r– 1 root root   60 Aug 10 17:47 pip-selfcheck.json
 jiandaoweixin ll bin 
total 56K
-rw-r–r– 1 root root 2.1K Aug 10 17:47 activate
-rw-r–r– 1 root root 1.1K Aug 10 17:47 activate.csh
-rw-r–r– 1 root root 2.2K Aug 10 17:47 activate.fish
-rw-r–r– 1 root root 1.2K Aug 10 17:47 activate_this.py
-rwxr-xr-x 1 root root  277 Aug 10 17:46 easy_install
-rwxr-xr-x 1 root root  277 Aug 10 17:46 easy_install-2.6
-rwxr-xr-x 1 root root  249 Aug 10 17:46 pip
-rwxr-xr-x 1 root root  249 Aug 10 17:46 pip2
-rwxr-xr-x 1 root root  249 Aug 10 17:46 pip2.6
-rwxr-xr-x 1 root root 8.9K Aug 10 17:46 python
lrwxrwxrwx 1 root root    6 Aug 10 17:46 python2 -> python
lrwxrwxrwx 1 root root    6 Aug 10 17:46 python2.6 -> python
-rwxr-xr-x 1 root root 2.4K Aug 10 17:47 python-config
-rwxr-xr-x 1 root root  256 Aug 10 17:46 wheel

(jiandaoweixin)  jiandaoweixin which python
/usr/share/nginx/html/jiandaoweixin/jiandaoweixin/bin/python
(jiandaoweixin)  jiandaoweixin deactivate 
 jiandaoweixin which python
/usr/bin/python
 jiandaoweixin source bin/activate
(jiandaoweixin)  jiandaoweixin which python       
/usr/share/nginx/html/jiandaoweixin/jiandaoweixin/bin/python
(jiandaoweixin)  jiandaoweixin

可以通过:

source bin/activate

进入虚拟环境

通过:

deactivate

退出虚拟环境了。

然后再去折腾:virtualenvwrapper

[记录]CentOS中安装和使用virtualenvwrapper

然后后来,不小心把virtualenv的环境删除了。

需要重新建立环境。

转载请注明:在路上 » [记录]CentOS中安装和使用virtualenv

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.142 seconds, using 22.09MB memory