The simple line in the console
/usr/bin/2to3- -w /Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site-packages/uncertainties
Makes the packages to work, however I have not succeeded to make an automatic run inside a script. So far I do
pip_install('lmfit')
# Correct uncertainties
e2to3lib = Path(site.getsitepackages()[0]).parent
sys.path.append(str(e2to3lib))
e2to3 = shutil.which("2to3")
if not e2to3:
pip_install('2to3')
if sys.platform.startswith('win'):
e2to3 = Path(shutil.which("conda")).parent / '2to3.exe' # Windows
else:
e2to3 = Path(shutil.which("python3")).parent / '2to3-' # MACOS
if not e2to3.exists:
e2to3 = Path(shutil.which("python3")).parent / '2to3' # Linux
uncertainties = Path(site.getsitepackages()[0]) / "uncertainties"
try:
print(subprocess.check_output([str(e2to3), "-w", str(uncertainties)],shell=True,stderr=subprocess.STDOUT, env=startupEnvironment()))
except subprocess.CalledProcessError as e:
raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
import lmfit
But this fails with this error:
subprocess.CalledProcessError: Command '['/usr/bin/2to3-', '-w', '/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site-packages/uncertainties']' returned non-zero exit status 2.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/imp.py", line 170, in load_source
module = _exec(spec, sys.modules[name])
File "<frozen importlib._bootstrap>", line 618, in _exec
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/alexvergaragil/Documents/GIT/dosimetry4d/Dosimetry4D/Dosimetry4D.py", line 21, in <module>
from Logic import Dosimetry4DLogic, Dosimetry4DTest, dicomutils, vtkmrmlutils, vtkmrmlutilsTest, testutils, xmlutils, xmlutilsTest, nodes, nodesTest, errors, config, logging, sentry, utils, export
File "/Users/alexvergaragil/Documents/GIT/dosimetry4d/Dosimetry4D/Logic/__init__.py", line 1, in <module>
from .Dosimetry4DLogic import *
File "/Users/alexvergaragil/Documents/GIT/dosimetry4d/Dosimetry4D/Logic/Dosimetry4DLogic.py", line 32, in <module>
from Logic.fit_values import fit_values
File "/Users/alexvergaragil/Documents/GIT/dosimetry4d/Dosimetry4D/Logic/fit_values.py", line 41, in <module>
raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
RuntimeError: command '['/usr/bin/2to3-', '-w', '/Applications/Slicer.app/Contents/bin/../lib/Python/lib/python3.6/site-packages/uncertainties']' return with error (code 2): b'At least one file or directory argument required.\nUse --help to show usage.\n'