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.

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].

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

I loosely followed this tutorial except (maybe) that I didn't create a directory for the virtualenvs (the $ mkdir ~/.virtualenvs command).

Now my user is stuck within the (general) environment and I can't get out.

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...

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

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.

The questions

  • how can I deactivate the (general) environment
  • 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; 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.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.