Within the virtual environment, the local site-packages will take
precedence over the system site-packages. So if the same module name
appears in both, the local one will be imported.
It sounds like your use case would be satisfied by this. But if you
need to test what would happen if you remove a package entirely, I
don't know of a particularly robust or accurate way to do this. I
think your best bet for this is to create your own stub module with
the name you're trying to block, and just have nothing in it, and put
this empty module in your virtual environment's site-packages. (Or,
instead of being empty, you could make it raise ImportError
Python provides a lot of introspection. I encourage you to use it. For
example, if you are not sure whether the virtual environment's
site-packages is ahead of the system site-packages, fire up Python
from within the virtual environment, import sys, and check out what
sys.path is. (That is what I did to confirm my answer to your
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
Help support midrange.com by shopping at amazon.com with our affiliate
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.