为什么我不能“停用"?pyenv/虚拟环境?如何“修复"安装 [英] Why can't I "deactivate" pyenv / virtualenv? How to "fix" installation
问题描述
我使用的是全新安装的 Ubuntu 16.04,鉴于使用最新版本的 pandas 进行开发,我安装了 Python 3.6.0虚拟环境.
I am on a freshly installed Ubuntu 16.04 and in view of developing with recent versions of pandas I installed Python 3.6.0 using a virtual environment.
选择 3.6.0 的一个原因是因为我在某处读到此版本的 Python 可以本地处理虚拟环境,即无需安装任何其他东西 [无论如何安装 3.6.0 本身而不替换系统范围的 Python,这将有几乎肯定是错的,实际上我之前必须提供一个虚拟环境].
A reason for choosing 3.6.0 was because I read somewhere that this version of Python could deal with virtual environments natively, i.e. without installing anything else [anyway to install 3.6.0 itself without replacing the system wide Python, which would have been almost surely wrong, I actually had to provide a virtual environment before].
我乐观地认为一切都会朝着正确的方向发展(包括我的知识),因此,我不太在意以下之间的差异:pyenv、pyenv-virtualenv、pyvenv 等...所以我不太记得我安装了什么,无论如何我只使用了 apt
和 pip
/pip3
,试图将 virtualenv 中的更改限制为一上架
I did it optimistically thinking that everything would go in the right direction (including my knowledge) and so, without caring too much about the differences between: pyenv, pyenv-virtualenv, pyvenv, etc...
So I don't remember well what I installed, anyway I used only apt
and pip
/pip3
, trying to confine changes within the virtualenv as soon as it became available
我松散地遵循了这个教程,除了(也许)我没有为 virtualenvs 创建一个目录($ mkdir ~/.virtualenvs
命令).
I loosely followed this tutorial except (maybe) that I didn't create a directory for the virtualenvs (the $ mkdir ~/.virtualenvs
command).
现在我的用户被困在 (general)
环境中,我无法出去.
Now my user is stuck within the (general)
environment and I can't get out.
登录后一开始,没有激活任何环境,bash给了我一个修改后的提示,似乎我无法通过deactivate
,sourcedeactivate<获得通常的提示/code> 等...
Right from the start after the login, without activating any environement, bash gives me a modified prompt, and it seems I can't get the usual prompt by deactivate
, source deactivate
, etc...
(general) $ deactivate
pyenv-virtualenv: deactivate must be sourced. Run 'source deactivate' instead of 'deactivate'
(general) $ source deactivate
pyenv-virtualenv: deactivate 3.6.0/envs/general
(general) $ pyvenv deactivate
pyenv: pyvenv: command not found
The `pyvenv` command exists in these Python versions: 3.6.0
(general) $
您会看到 (general)
前缀保留在提示中.
You see that the (general)
prefix remains in the prompt.
我也有过这种 pyenv/virtualenv 设置影响系统活动的症状(例如,在尝试从命令行安装 hplip 时,安装程序在尝试识别我的操作系统时感到困惑,最终失败了 - 我不得不这样做来自另一个用户,然后它起作用了),所以我需要将其恢复为干净状态.
I have also had symptoms that this pyenv/virtualenv setup is affecting system activities (e.g. while trying to install hplip from the command line, the installer got confused when trying to recognize my os, and ultimately failed - I had to do it from another user, and then it worked), so I need to revert this to a clean state.
注意.我不确定我的安装是否真的有错,也许只是我发出了错误的命令或我遇到的一些常见陷阱.
NB. I am not that sure that my installation is really that wrong, maybe it's just me issuing the wrong commands or some common pitfall I have incurred in.
- 我如何
停用
(通用)环境 - 如何判断我的安装是否有误,以及如何修复
- 我怎样才能安全地从此安装恢复并使用更合适的安装?
我已经阅读了这个问题但它不是与我的案子关系不大
I have already read this question but it wasn't so tied to my case
这个似乎更相关,因为它突出显示a) python venv
应该是首选;b) 它在 Python >=3.3 上可用,c) ubuntu-xenial 没有默认安装它,d) 它给出了安装它的包名.
This one seems more related, in that it higlights that a) python venv
should be preferred; b) it is available on Python >=3.3, c) ubuntu-xenial doesn't have it already installed by deafult, d) it gives package names to install it.
但我仍然不确定在安装之前要卸载什么以防万一.
But still I am unsure of what to uninstall before installing them in case.
以下是 TAB 补全、命令和目录列表的输出,以显示我所处的环境:
Here are the outputs of TAB completions, commands, and a directory listing, to show a bit of which environment I am in:
(general) $ cat .py <TAB>
.pyenv/ .python_history
(general) $ cat .pyenv/ <TAB>
.agignore completions/ LICENSE shims/ versions/
bin/ CONDUCT.md Makefile src/ .vimrc
cache/ .git/ plugins/ test/
CHANGELOG.md .gitignore pyenv.d/ .travis.yml
COMMANDS.md libexec/ README.md version
(general) $ cat .pyenv/version
general
(general) $ ls -l ~/.pyenv/versions
totale 12
drwxrwxr-x 3 myuser myuser 4096 apr 20 13:50 ./
drwxrwxr-x 13 myuser myuser 4096 apr 20 13:50 ../
drwxr-xr-x 7 myuser myuser 4096 apr 20 13:50 3.6.0/
lrwxrwxrwx 1 myuser myuser 48 apr 20 13:50 general -> /home/myuser/.pyenv/versions/3.6.0/envs/general/
我尝试列出已安装的内容,但恐怕使用 pip3 list
我得到的答案是针对我卡住的环境,并且这掩盖了我安装的任何内容 在开始之前.
I tried listing what installed, but I'm afraid that with pip3 list
the answer I get is for the env where I am stuck, and that this is masking anything that I installed before getting to it.
可能只是我错误地从我的主目录安装了 pyenv?删除/移动 .pyenv
目录就足够了吗?我没有足够的信心不问就去做.
May it just be that I mistakenly installed pyenv from my home directory? Would it be enough to delete/move the .pyenv
directory? I am not confident enough to do it without asking.
推荐答案
DEACTIVATE 默认 PyEnv General 的方法是 --pyenv uninstall 3.6.0/envs/general
The way to DEACTIVATE the default PyEnv General is --pyenv uninstall 3.6.0/envs/general
(general) dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv uninstall 3.6.0/envs/generalpyenv-virtualenv:删除/home/dhankar/.pyenv/versions/3.6.0/envs/general?是dhankar@dhankar-VPCEB44EN:~/.pyenv$
加倍确保 PyENV 已被删除 --
to doubly ensure that the PyENV has been removed --
<代码>dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv 版本pyenv:未安装general"版本(由/home/dhankar/.pyenv/version 设置)系统3.6.03.6.5dhankar@dhankar-VPCEB44EN:~/.pyenv$
还要记录下来 - 在卸载之前共享同一命令的终端输出.
Also so that its documented - am sharing the terminal output of the same command , earlier before the Un-Install.
<代码>(一般) dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv 版本系统3.6.03.6.0/环境/通用3.6.5* 一般(由/home/dhankar/.pyenv/version 设置)(一般) dhankar@dhankar-VPCEB44EN:~/.pyenv$
这篇关于为什么我不能“停用"?pyenv/虚拟环境?如何“修复"安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!