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
As an Amazon Associate we earn from qualifying purchases.
This thread ...
Re: [IBMiOSS] ibm-db and itoolkit into venv, (continued)
This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.