Nice one thanks John that's helpful

On Mon, 1 Apr 2019 at 17:34, John Yeung <gallium.arsenide@xxxxxxxxx> wrote:

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
immediately.)

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
question.)

John Y.
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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 [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.