Can we use library installed in one virtual environment from another virtual environment?
For eg:
Library installed in venv from another virtual environment.
Asked
Active
Viewed 945 times
0

pppery
- 3,731
- 22
- 33
- 46

Subash Shrestha
- 61
- 7
-
Why do you want to do that? – Neil Sep 02 '19 at 15:16
-
Just as a query .There are so many library installed in one environment and I don't want to use same environment . Is it possible or not. ? – Subash Shrestha Sep 02 '19 at 15:18
-
If you don't want to use the same environment, don't. If you need some of the libraries from the old environment, re-install them in the new one. Use a requirements.txt to help with this. But yea this is a bit like asking if boats can drive on land. Maybe. – Neil Sep 02 '19 at 15:20
-
Even if this is possible, it is a very bad idea. You would be creating cross-dependencies between environments, which defeats their whole purpose. – jhansen Sep 02 '19 at 15:47
2 Answers
-1
Short answer: No
Virtual environment's purpose is to isolate different python instalation, including their libraries. If you ever find a way to do this, it must be considered a hack and should be reported to virtual environment as a bug.

Adirio
- 5,040
- 1
- 14
- 26
-
Thanks for the information but checkout above answers. Is it ok or not? – Subash Shrestha Sep 02 '19 at 15:50
-
It is way easier to reinstall or just clone the virtualenv to create a new one, if you were able to include a library from another virtualenv, it will look for its dependecies in the new virtaulenv that doesn't have them. – Adirio Sep 03 '19 at 07:34
-1
It should be possible, you just have to import the module by giving the full path to the module present in the source virtualenv. How to import a module given the full path?
But it'll NOT WORK as dependencies to the module will not be present in your target virtualenv. You can try importing all dependencies by using full path it'll work that way.

moghya
- 854
- 9
- 18
-
Is it possible or not. You are saying it is possible and not work at same time. – Subash Shrestha Sep 02 '19 at 15:52