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

[已解决]CentOS中退出了virtualenv之后如何再进入之前virtualenv

CentOS crifan 3172浏览 0评论

之前用SecureCRT通过SSH2去连接远程的CentOS服务器

去折腾Python的Flask开发,期间用到虚拟环境:virtualenvwrapper(和virtualenv)

但是在连接超时后:

再次进入后,就丢失了该环境

不知道如何进去该虚拟环境了。

virtualenvwrapper 如何再次进入

如何离开/退出/停用Python的virtualenv? | Stackoverflow about Python

使用virtualenv创建虚拟python环境 | the5fire的技术博客

创建并进入环境:mkvirtualenv env1

退出环境:deactivate

进入已存在的环境或者切换环境:workon env1或者env2

删除环境: rmvirtualenv env1

去试试,结果找不到:

[已解决]CentOS中virtualenvwrapper出错:zsh command not found workon

然后就可以进入到之前的虚拟环境了:

也可以看到之前安装好的Flask了:

 ~ workon SIPEvents 
(SIPEvents)  ~ ll
total 28K
drwxr-xr-x 6 root root 4.0K Jun  3 23:40 _book
drwxr-xr-x 3 root root 4.0K Aug 15 12:04 Envs
drwxrwxrwx 3 root root 4.0K Jun 11 17:22 frontend
drwxr-xr-x 2 root root 4.0K Jun  5 19:37 gitlib
lrwxrwxrwx 1 root root   21 Aug 15 09:52 html -> /usr/share/nginx/html
drwxr-xr-x 5 root root 4.0K Jun  3 21:49 mytaiga
drwxr-xr-x 2 root root 4.0K Aug 15 21:24 SIPEvents
drwxr-xr-x 2 root root 4.0K Aug 15 11:59 tools
(SIPEvents)  ~ flask –help
Usage: flask [OPTIONS] COMMAND [ARGS]…
  This shell command acts as general utility script for Flask applications.
  It loads the application configured (either through the FLASK_APP
  environment variable) and then provides commands either provided by the
  application or Flask itself.
  The most useful commands are the “run” and “shell” command.
  Example usage:
    $ export FLASK_APP=hello
    $ export FLASK_DEBUG=1
    $ flask run
Options:
  –help  Show this message and exit.
Commands:
  run    Runs a development server.
  shell  Runs a shell in the app context.
(SIPEvents)  ~

然后可以通过deactivate去退出虚拟环境:

(SIPEvents)  ~ deactivate 
 ~

【总结】

借用别人总结的:

  • 创建并进入环境:mkvirtualenv env1
  • 退出环境:deactivate
  • 进入已存在的环境或者切换环境:workon env1或者env2
  • 删除环境: rmvirtualenv env1

转载请注明:在路上 » [已解决]CentOS中退出了virtualenv之后如何再进入之前virtualenv

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.170 seconds, using 22.08MB memory