I use a script under virtualenv, that requires bzrlib package which is not available in my virtualenv but is included in my system python packages: /usr/lib/python2.7/dist-packages/bzrlib/
If I want to use it, one option is to extend sys.path, but I would have to include the parent folder /usr/lib/python2.7/dist-packages/
which contains many other packages, that I don't want to make available. Is there any easy way to include just bzrlib
package?
What about creating a link in different directory and importing using that? Or even in your own project.
ln -s /package/dir/path /project/dir/path
If you have to load it remotely, here is the link provided by @unutbu showing how to do it:
How to import a module given the full path?
import imp
foo = imp.load_source('module.name', '/path/to/file.py')
foo.MyClass()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.