1

I have installed virtualenv on my system using http://www.pythonforbeginners.com/basics/how-to-use-python-virtualenv

according to these guidelines, the initial step is:

$ sudo apt-get install python-pip python-dev python-virtualenv

However, I do not want to touch my parent environment. The only reason I believe virtualenv might be of some help for my case is because I have some weird errors that point to python version inconsistencies.

So my requirements are:

  • virtualenv with e.g. python 3.5
  • tensorflow
  • no influence on my parent environment
  • ability to disable virtualenv with no side effects

Is it doable how?

joseph pareti
  • 97
  • 1
  • 9
  • This is exactly what virtualenv is done for. Did you try and have a problem with it? – Dric512 May 08 '18 at 16:48
  • @Dric512 - He doesn't know how to install it, except by using `sudo apt-get`, which he is loathe to do. The question is: "How does one install virtualenv without disturbing the system installation"? – Robᵩ May 08 '18 at 16:51
  • Joseph, I find [`pyenv`](https://github.com/pyenv/pyenv) much more convenient, and it satisfies all of your requirements. – Robᵩ May 08 '18 at 16:52

3 Answers3

0

create the env

virtualenv -p python3 path/to/your/env

activate the env

source path/to/your/env/bin/activate

install packages

pip install pkgname

deactivate

deactivate

If you do not want to touch your parent environment, install package using pip after activating the environment. Next time you activate the environment, the installed packages will remain there. If you want to delete the environment, just delete the folder path/to/your/env.

harvpan
  • 8,571
  • 2
  • 18
  • 36
0

You could follow the steps in this answer for instance, which will be essentially the same as the guide you've mentioned.

virtualenv installs libraries and all in a subfolder of your main system, and directs python to only use those, so they don't interfere with your main installation.

If you really don't want to touch anything in your system, you could always run tensorflow in a docker container (see this answer for some tips). But even that will require some installation in the "parent" system.

Laurent S
  • 4,106
  • 3
  • 26
  • 50
0

Just run this single command:

  • It installs python package manager: pip.
  • It creates a virtual environment named: my_env.
  • It activates the virtual environment.

sudo apt-get install python3-pip -y && sudo apt install python3.8-venv && python3 -m venv my_env/ && source my_env/bin/activate

Md. Shahariar Hossen
  • 1,367
  • 10
  • 11