简体   繁体   English

为什么我不能“停用”pyenv / virtualenv? 如何“修复”安装

[英]Why can't I "deactivate" pyenv / virtualenv? How to "fix" installation

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.我在新安装的Ubuntu 16.04上,考虑到使用最新版本的pandas进行开发,我使用虚拟环境安装了Python 3.6

A reason for choosing 3.6.0 was because I read somewhere that this version of Python could deal with virtual environments natively, ie 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].选择 3.6.0 的一个原因是因为我在某处读到此版本的 Python 可以原生处理虚拟环境,即无需安装任何其他东西[无论如何安装 3.6.0 本身而不更换系统范围的 Python,这几乎可以肯定错了,我之前实际上必须提供一个虚拟环境]。

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我乐观地认为 go 会朝着正确的方向发展(包括我的知识),所以,没有太在意 pyenv、pyenv-virtualenv、pyvenv 等之间的区别……所以我不太记得是什么我安装了,无论如何我只使用了aptpip / pip3 ,试图在 virtualenv 可用时将更改限制在其中

I loosely followed this tutorial except (maybe) that I didn't create a directory for the virtualenvs (the $ mkdir ~/.virtualenvs command).除了(可能)我没有为 virtualenvs 创建目录( $ mkdir ~/.virtualenvs命令)之外,我松散地遵循了本教程

Now my user is stuck within the (general) environment and I can't get out.现在我的用户被困在(general)环境中,我无法离开。

Situation情况

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...从登录后开始,没有激活任何环境,bash 给了我一个修改过的提示,似乎我无法通过deactivatesource deactivate等获得通常的提示......

(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) $ 

You see that the (general) prefix remains in the prompt.您会看到(general)前缀保留在提示中。

I have also had symptoms that this pyenv/virtualenv setup is affecting system activities (eg 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.我也有这种 pyenv/virtualenv 设置影响系统活动的症状(例如,在尝试从命令行安装 hplip 时,安装程序在尝试识别我的操作系统时感到困惑,最终失败 - 我不得不从另一个用户那里完成,然后它起作用了),所以我需要将其恢复为干净的 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.我不确定我的安装是否真的那么错误,也许只是我发出了错误的命令或者我遇到了一些常见的陷阱。

The questions问题

  • how can I deactivate the (general) environment如何deactivate (一般)环境
  • how can I tell if my installation is wrong, and how can I fix it如何判断我的安装是否错误,以及如何修复
  • how can I safely revert from this installation and get to a more proper one?我怎样才能安全地从此安装恢复并获得更合适的安装?

I have already read this question but it wasn't so tied to my case我已经读过这个问题,但它与我的情况并没有太大关系

This one seems more related, in that it higlights that a) python venv should be preferred; 似乎更相关,因为它强调 a) python venv应该是首选; 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. b) 它在 Python >=3.3 上可用,c) ubuntu-xenial 没有默认安装它,d) 它提供 package 名称来安装它。

But still I am unsure of what to uninstall before installing them in case.但是我仍然不确定在安装它们之前要卸载什么以防万一。

More info更多信息

Here are the outputs of TAB completions, commands, and a directory listing, to show a bit of which environment I am in:以下是 TAB 完成、命令和目录列表的输出,以显示我所处的环境:

(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/

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.我尝试列出已安装的内容,但恐怕使用pip3 list我得到的答案是针对我被卡住的环境,这掩盖了我在安装之前安装的任何内容。

May it just be that I mistakenly installed pyenv from my home directory?可能只是我错误地从我的主目录安装了 pyenv 吗? Would it be enough to delete/move the .pyenv directory?删除/移动.pyenv目录就足够了吗? I am not confident enough to do it without asking.我没有足够的信心不问就去做。

The way to DEACTIVATE the default PyEnv General is --pyenv uninstall 3.6.0/envs/general DEACTIVATE默认PyEnv General的方法是--pyenv uninstall 3.6.0 / envs / general

(general) dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv uninstall 3.6.0/envs/general pyenv-virtualenv: remove /home/dhankar/.pyenv/versions/3.6.0/envs/general? y dhankar@dhankar-VPCEB44EN:~/.pyenv$

to doubly ensure that the PyENV has been removed -- 双重确保PyENV已被删除 -

dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv versions pyenv: version `general' is not installed (set by /home/dhankar/.pyenv/version) system 3.6.0 3.6.5 dhankar@dhankar-VPCEB44EN:~/.pyenv$

Also so that its documented - am sharing the terminal output of the same command , earlier before the Un-Install. 还要记录它 - 在Un-Install之前共享同一命令的终端输出。

(general) dhankar@dhankar-VPCEB44EN:~/.pyenv$ pyenv versions system 3.6.0 3.6.0/envs/general 3.6.5 * general (set by /home/dhankar/.pyenv/version) (general) dhankar@dhankar-VPCEB44EN:~/.pyenv$

It was deactivated when I used this command: pyenv shell <python_version>当我使用这个命令时它被停用: pyenv shell <python_version>

Example: pyenv shell 3.10.5示例: pyenv shell 3.10.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使安装了 pyenv-virtualenvwrapper,pyenv 也无法制作 virtualenv - pyenv can't make virtualenv even with pyenv-virtualenvwrapper installed 如何在virtualenv`deactivate`上运行清理脚本? - How can I run a cleanup script on virtualenv `deactivate`? 如何停用 pyenv? - How to deactivate pyenv? python `deactivate` 命令无法退出 virtualenv - python `deactivate` command can't exit virtualenv 除了 OSX 上现有的 pyenv 安装外,如何安装 Anaconda? - How can I install Anaconda aside an existing pyenv installation on OSX? 在`pyenv/pyenv-virtualenv`中,我可以创建一个引用`system`的virtualenv,即之前没有`pyenv install`吗? - in `pyenv/pyenv-virtualenv` can I create a virtualenv which refers to `system`, i.e. without a `pyenv install` before? 为什么我不能在我的主Python安装文件夹中插入安装包? Virtualenv妨碍了? - Why can't I pip install packages in my main Python installation folder? Virtualenv getting in the way? 如何在 pyenv 中创建一个 post virtualenv 钩子来升级 pip 包 - How can I make a post virtualenv hook in pyenv to upgrade pip packages 如何让 AWS Chalice 使用 pyenv virtualenv python 版本? - How can I get AWS Chalice to use pyenv virtualenv python version? 使用 pyenv,我 pip 如何安装全局 CLI 并使它们即使在 virtualenv 中也可用? - Using pyenv, how can I pip install global CLIs and make them available even when in a virtualenv?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM