1👍
✅
Create your environment with the --system-site-packages
option. Once you are in the virtual environment, if you try to import a package that isn’t installed, it will try to find it in the global site packages and only if it can’t find it there will it raise an ImportError
.
This is by far the simplest way to do what you are trying on Windows – short of creating your own build environment – which I can tell you from my experience isn’t always guaranteed to work.
If you do go with this approach, make sure you still add the package (and ideally pin it) in your requirements.txt
file. This way if you were to deploy it on another environment, you will not miss any dependencies.
Source:stackexchange.com