
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to install some third party packages into the Fusion python interpreter in a robust way. I understand one solution is to just include the dependency source code directly within my add-in. I don't want to do this. Instead, I'm trying to run pip from within the python interpreter to install directly to the Fusion python. I tried the following script:
import adsk.core, adsk.fusion, adsk.cam, traceback def run(context): ui = None try: text = "Lorem ipsum dolor sit amet" def install_and_import(package): import importlib try: importlib.import_module(package) except ImportError: import pip pip.main(['install', package]) finally: globals()[package] = importlib.import_module(package) app = adsk.core.Application.get() ui = app.userInterface install_and_import('transliterate') msg = transliterate.translit(text, 'hy') ui.messageBox(msg) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
It should install transliterate package, but instead, when running the command pip.main(['install', package]) all I get is the following message:
Collecting transliterate Downloading transliterate-1.10-py2.py3-none-any.whl (49kB) 2
The console in Spyder never shows a message that the package was actually installed... it was just downloaded. I checked the same command on my own python interpreter (3.6), and it worked fine, giving a downloading, collecting and installing message. My question is: what did I do wrong? and how do I get pip to successfully install a package?
Solved! Go to Solution.