Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: Hunter on May 29, 2019, 04:05:49 PM
-
I'm having trouble installing external python modules to Metashape and hoping someone can provide some insight. I've read the Metashape manual and Python addendum and have tried the following:
1. $.../metashape-pro/python/bin$ ./python3.5 -m pip install Pillow
Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (6.0.0)
(similar results for module Image and module exifread)
Next, I start Metashape and attempt to run my script by clicking tools->run script (script starts with the following lines and errors on line 2):
import Metashape
from PIL import Image
import PIL.ExifTags
and get the message box "No module named 'PIL'"
2. I installed libssl 0.9.8 (as shown on https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package))
3. Tried #1 again, but same result.
4. One oddity, when I type:
$.../metashape-pro/python/bin$ ./python3.5
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Notice that it runs the default python install on my machine (3.7.3).
5. $.../metashape-pro/python/bin$ ./pip install Pillow
bash: ./pip: /opt/python3.5/bin/python3.5m: bad interpreter: No such file or directory
6. $uname -a
Linux <computername> 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Any ideas? (Thanks in advance)
-
Hello Hunter,
Which OS version you are using?
It seems that there's something messed up with the dependencies. I've tried to follow the same approach and have properly installed Pillow on the clean Ubuntu system, and the module is working from Metashape console now.
-
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 19.04
Release: 19.04
Codename: disco
Thanks for the quick response.
-
Hello Hunter,
Can you please execute the following command from the Metashape Pro installation directory:
LD_LIBRARY_PATH=`pwd`/python/lib python/bin/python3.5 --version
If it shows Python 3.5.2, please try the installation using the following commands:
cd <path_to_metashape-pro>
LD_LIBRARY_PATH=`pwd`/python/lib ./python/bin/python3.5 -m pip install python_module_name
-
Thanks Alexey.
I was able to eventually solve the problem by rolling back to Ubuntu 18.04. Desktop install with nothing special. I then copied libpython3.5m.so.1.0 to the metashape/python/bin folder. Finally, I ran...
sudo ./python3.5 -m pip install Pillow
and it installed correctly. I then started Metashape and my python script to extract and use metadata in the EXIF fields worked great. Thanks again for the support!
-
Hello Hunter,
Can you please execute the following command from the Metashape Pro installation directory:
LD_LIBRARY_PATH=`pwd`/python/lib python/bin/python3.5 --version
If it shows Python 3.5.2, please try the installation using the following commands:
cd <path_to_metashape-pro>
LD_LIBRARY_PATH=`pwd`/python/lib ./python/bin/python3.5 -m pip install python_module_name
I am having this same issue. I followed these instructions, but now I am stuck at the issue that is mentioned in the link posted at the top for external library install:
In case Linux installation doesn't work due to any reason (like ImportError: cannot import name 'HTTPSHandler') please install libssl 0.9.8 (as shown below) and repeat pip install process:
wget http://snapshot.debian.org/archive/debian/20110406T213352Z/pool/main/o/openssl098/libssl0.9.8_0.9.8o-7_amd64.deb
sudo dpkg -i libssl0.9.8_0.9.8o-7_amd64.deb
I don't have sudo on my machine though, is there any other good solution?
-
Hi I figured it out. I needed to include a different python lib for LD_LIBRARY_PATH as well, since the metashape (1.6.2 pro) version I have installed had the HTTPSHandler issue.
LD_LIBRARY_PATH=/path/to/metashape-pro/python/lib:/path/to/anaconda3/envs/py35/lib; metashape-pro/python/bin/python3.5 -m pip install python_module_name
this finally worked
-
I'm having the same error with Ubuntu 20.04 and Metashape 1.5.5:
ImportError: cannot import name 'HTTPSHandler'
I installed libssl according to https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package)
Default Python is 3.8 but even did an alt install of 3.5.2. Still getting the same HTTPSHandler error when running this command:
LD_LIBRARY_PATH=/usr/local/metashape-pro/python/lib:/usr/local/bin/python3.5:/usr/local/lib/python3.5:/usr/lib/x86_64-linux-gnu ./python3.5 -m pip install numpy
Should I revert back to an earlier Ubuntu release and/or upgrade to the latest Metashape? (Dragging my feet on upgrading to latest Metashape because it would involve rewriting a lot of code for the API..)
-
I'm having the same error with Ubuntu 20.04 and Metashape 1.5.5:
ImportError: cannot import name 'HTTPSHandler'
I installed libssl according to https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package)
Default Python is 3.8 but even did an alt install of 3.5.2. Still getting the same HTTPSHandler error when running this command:
LD_LIBRARY_PATH=/usr/local/metashape-pro/python/lib:/usr/local/bin/python3.5:/usr/local/lib/python3.5:/usr/lib/x86_64-linux-gnu ./python3.5 -m pip install numpy
Should I revert back to an earlier Ubuntu release and/or upgrade to the latest Metashape? (Dragging my feet on upgrading to latest Metashape because it would involve rewriting a lot of code for the API..)
As an update, I'm seeing the same "HTTPSHandler" issue with Ubuntu 20.04 and the latest Metashape (1.6.2)
-
I'm having the same error with Ubuntu 20.04 and Metashape 1.5.5:
ImportError: cannot import name 'HTTPSHandler'
I installed libssl according to https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package)
Default Python is 3.8 but even did an alt install of 3.5.2. Still getting the same HTTPSHandler error when running this command:
LD_LIBRARY_PATH=/usr/local/metashape-pro/python/lib:/usr/local/bin/python3.5:/usr/local/lib/python3.5:/usr/lib/x86_64-linux-gnu ./python3.5 -m pip install numpy
Should I revert back to an earlier Ubuntu release and/or upgrade to the latest Metashape? (Dragging my feet on upgrading to latest Metashape because it would involve rewriting a lot of code for the API..)
As an update, I'm seeing the same "HTTPSHandler" issue with Ubuntu 20.04 and the latest Metashape (1.6.2)
SOLVED (for now): As another update, this works perfectly normally with Ubuntu 18.04. So, I would suggest sticking with the older Ubuntu release until a workaround for 20.04 is determined.
-
Hi,
The same thing happened here on Arch Linux. I already installed either the openssl098 as suggested https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-photoscan-professional-pacakge (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-photoscan-professional-pacakge) or the latest openssl, but still got the HTTPSHandler error. Here's the command and output I tried to execute:
command:
LD_LIBRARY_PATH=/opt/agisoft/metashape-pro/python/lib /opt/agisoft/metashape-pro/python/bin/python3.5 -m pip install --user Pillow
output:
Traceback (most recent call last):
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 174, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 133, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/_vendor/distlib/compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler'
The metashape-pro version is 1.6.3, and I believe I used the correct python
$ LD_LIBRARY_PATH=/opt/agisoft/metashape-pro/python/lib /opt/agisoft/metashape-pro/python/bin/python3.5 --version
Python 3.5.2
Any suggestions to resolve this issue would be appreciated.
-
Hi @Alexey,
Just would like to know if your team started to investigate this? It seems that this issue affects many users. However, unlike Ubuntu users who can choose to roll back to an older release, users like Arch just simply can't resolve this issue by doing so. I looked up online and some answers suggested that it may be related to some out-dated virtual environment script. Hope this information help.
Hi,
The same thing happened here on Arch Linux. I already installed either the openssl098 as suggested https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-photoscan-professional-pacakge (https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-photoscan-professional-pacakge) or the latest openssl, but still got the HTTPSHandler error. Here's the command and output I tried to execute:
command:
LD_LIBRARY_PATH=/opt/agisoft/metashape-pro/python/lib /opt/agisoft/metashape-pro/python/bin/python3.5 -m pip install --user Pillow
output:
Traceback (most recent call last):
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 174, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 133, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/opt/agisoft/metashape-pro/python/lib/python3.5/site-packages/pip/_vendor/distlib/compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler'
The metashape-pro version is 1.6.3, and I believe I used the correct python
$ LD_LIBRARY_PATH=/opt/agisoft/metashape-pro/python/lib /opt/agisoft/metashape-pro/python/bin/python3.5 --version
Python 3.5.2
Any suggestions to resolve this issue would be appreciated.
-
As a workaround you can try to download packages with system python and then install it in bundled python:
1. Install system python 3.5
2. Make empty dir and cd to it (mkdir pip_packages and cd pip_packages)
3. python3.5m -m pip download Pillow
4. wait for downloading all packages (including dependencies)
5. LD_LIBRARY_PATH=python/lib/ python/bin/python3.5m -m pip install --upgrade --no-index --find-links=pip_packages Pillow