0

I had a virtual environment called venv on a raspberry pi. I copied it to my pc via scp -r rpi@rpiip:~/venv ., then deleted it from the pi with sudo rm -r venv

Then I copied the venv folder back to the pi via scp. The folder is exactly the same size as on my PC, so it's definitely the same venv folder, however now my scripts don't work. None of the libraries are able to be found!

Is it possible to restore the old venv to working condition? Why aren't any of my libraries found after restoring the virtual environment?

EDIT:

Is this behaviour uncharacteristic of virtualenv? Or is it normal for a virtualenv not to be completely self contained like this?

EDIT2:

After activating, the pip command returns

from pip._internal import main
ImportError: No module named 'pip._internal'
A_toaster
  • 1,196
  • 3
  • 22
  • 50
  • I assume you activated the virtual env again? Is there something preventing just recreating? – Tim May 30 '19 at 03:03
  • @Tim Yes, I've definitely activated it, I would like to not recreate it as it contains `dlib` and `scipy`, both of which take hours to build on RPi. I can see all the libraries are there, but pip seems to not work anymore. – A_toaster May 30 '19 at 03:09
  • Added update to question – A_toaster May 30 '19 at 03:10
  • Is the copy of the venv located at the exact same path as the original venv? – jwodder May 30 '19 at 03:24
  • @jwodder Yep! I copied it to my local pc then copied the exact folder back. When i `ls -l` in the parent directory I can see that the exact same folder exists – A_toaster May 30 '19 at 04:07
  • https://stackoverflow.com/a/53964819/7976758 – phd May 30 '19 at 08:43
  • One tip I can suggest to avoid having to recompile `dlib` and `scipy`, you can create your own wheel package specific to your environment using pip. `pip wheel -w /output/path scipy` will generate a precompiled wheel file. You can then just copy the wheel file around and because it is precompiled it will install quickly into a new virtualenv. Note this will need to be done on the RPi as I don't believe cross-compilation is supported. – Tim May 31 '19 at 01:39

0 Answers0