0

I'd I like to install virtualenv on an USB disk so that i can use it also on other computers. How can I do it? Just creating a virtualenv on the disk doesn't seem to work...

I'm using Mac and the target computer has Fedora.

L.A.
  • 243
  • 2
  • 12
  • You'll probably have to install the *Python* interpreter used to create the *VEnv* on that disk too. – CristiFati Nov 27 '18 at 22:43
  • https://stackoverflow.com/questions/39000975/create-a-virutalenv-on-another-drive-access-is-denied – The Pineapple Nov 27 '18 at 22:45
  • @CristiFati Probably I didn't explained well. `virtualenv` creates correctly the directory and it works fine on my computer, but it does not work on other computer – L.A. Nov 27 '18 at 22:51
  • Virtualenvs are not meant to be movable. Why not just pip freeze and recreate it on the target machine, like everyone else? – Nils Werner Nov 27 '18 at 23:00
  • [virtualenvs aren't portable](https://stackoverflow.com/search?q=%5Bvirtualenv%5D+relocatable). They're a development tool but not a distribution/deployment tool. – phd Nov 27 '18 at 23:04
  • @NilsWerner The target machine is the computer of physic lab in my university, where pip and virtualenv aren't installed, so I can't recreate it – L.A. Nov 27 '18 at 23:04
  • @phd Oh this is not good :(, do you know how can I create a virtualenv directly on the target computer if it hasn't `virtualenv` and `pip`? – L.A. Nov 27 '18 at 23:07
  • Yes, "doesn't seem to work" is not good enough. Check [\[SO\]: How to create a Minimal, Complete, and Verifiable example (mcve)](https://stackoverflow.com/help/mcve). – CristiFati Nov 28 '18 at 07:27
  • Python 3.4+ have [ensurepip](https://docs.python.org/3/library/ensurepip.html) and [venv](https://docs.python.org/3/library/venv.html) built in. – phd Nov 28 '18 at 09:10

2 Answers2

1

You should be able to do it using Winpython

Check out this answer: Using Virtualenv with Winpython from flash drive

edit based on the update about MacOs on comments

You can install using anaconda using silent install mode That was taken from: https://stackoverflow.com/a/45140556/4288795 The answer is for windows, but it should be adaptable to MacOs using the link above

Good luck on your projects!

Pedro Borges
  • 1,240
  • 10
  • 20
0

Short answer is YES but of no use.

The internal architecture used in Virtualenv, hard codes all the paths as absolute paths in multiple places. Most notably all the files in the "site-packages" folder contain hard coded paths and many or most of them are in ascii format. So there is no normal means to change them to a relative paths.

It may however work in a very restricted set of situation like if you can maintain the same folder path in all the computers and same family of os etc etc. But and its a really big 'but' whether even in this scenario it will work smoothly.

Unless there is vendor support from its architecture level you cannot get true portability.

Using pip-freeze with "requirements" file and recreating the virtualenv on all systems separately is the only option available as of now.