Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 copy a virtual environment to a new system
if i use venv to create a virtual environment can it be copied (like with rsync) as part of copying all home directories, to a new system running a newer version of python? for example i am currently running ubuntu 18.04 that has python 3.6 and next year (i'm making plans, now) i will install ubuntu 20.04 with a repartition and reformat of all partitions. everything will be backed up to each of three 2TB USB hard drives plus AWS S3. i expect 20.04 to have python 3.7 or later (whatever is out at package version freeze). i am looking at creating python virtual environments and have read about people having trouble when the system python is upgraded (other than a bugfix). i still don't have full details about how a virtual environment works. apparently, activating it is required every time a new shell is started so i presume i modifies shell settings which could be a problem for me since i run a very modified shell.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Moving can go bad,as OS environment Python version ect... can be different.
The relocatable option is deprecated and generally fails to solve the problem.
The fix or how meant to be should be used is run pip freeze > requirements.txt and recreate on new system with pip install -r requirements.txt.
$ oldenv/bin/pip freeze > requirements.txt
$ python -m venv newenv
$ newenv/bin/pip install -r requirements.txt
So can just keep requirements.txt for your virtual environments and recreate on new system.
In the big picture so is venv a dependency management tool,like also pipenv is.

A level above setuptools( to create wheels.
So a wheel contain everything dependencies,python files,can also have C binray/dependencies.
Can be moved around and installed with pip install my_wheel.whl
So PyPi is really a online a distribution of wheels(as wheel is what you upload to PyPi).

Poetry try to make this easier at higher level also it replace, requirements.txt, setup.cfg, and the newly added Pipfile.
To one file pyproject.toml
Poetry dos a good job trying to make this simpler.

In the picture is also Anaconda with there tool like pip which is conda.
So eg Miniconda is standalone and can be moved around.

So a little overview on this topic that's not so easy,but is better than it used to be Undecided
buran likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  virtual environment questions Skaperen 2 272 May-21-2019, 08:11 PM
Last Post: Skaperen
  PyCharm virtual environment (venv) issues? j.crater 1 556 Aug-14-2018, 10:22 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)