Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N2V demo prediction not working #56

Open
bpavie opened this issue Mar 13, 2024 · 1 comment
Open

N2V demo prediction not working #56

bpavie opened this issue Mar 13, 2024 · 1 comment

Comments

@bpavie
Copy link

bpavie commented Mar 13, 2024

Hi,

I installed everything, started napari and tried to run the N2V Demo prediction, but I get an SSL error:

(napari-n2v) >napari
WARNING: QWindowsWindow::setGeometry: Unable to set geometry 54x50+640+270 (frame: 76x101+629+230) on QWidgetWindow/"SpinBoxClassWindow" on "\\.\DISPLAY1". Resulting geometry: 148x50+640+270 (frame: 170x101+629+230) margins: 11, 40, 11, 11)
16:13:11 WARNING QWindowsWindow::setGeometry: Unable to set geometry 54x50+640+270 (frame: 76x101+629+230) on QWidgetWindow/"SpinBoxClassWindow" on "\\.\DISPLAY1". Resulting geometry: 148x50+640+270 (frame: 170x101+629+230) margins: 11, 40, 11, 11)
INFO: Downloading data can take a few minutes.
---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)
File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:1346, in AbstractHTTPHandler.do_open(self=<urllib.request.HTTPSHandler object>, http_class=<class 'http.client.HTTPSConnection'>, req=<urllib.request.Request object>, **http_conn_args={'check_hostname': None, 'context': None})
   1345 try:
-> 1346     h.request(req.get_method(), req.selector, req.data, headers,
        h = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>
        headers = {'Host': 'download.fht.org', 'User-Agent': 'Python-urllib/3.9', 'Connection': 'close'}
        req = <urllib.request.Request object at 0x000001E8FD7DB3A0>
        req.selector = '/jug/n2v/SEM.zip'
   1347               encode_chunked=req.has_header('Transfer-encoding'))
   1348 except OSError as err: # timeout error

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:1285, in HTTPConnection.request(self=<http.client.HTTPSConnection object>, method='GET', url='/jug/n2v/SEM.zip', body=None, headers={'Connection': 'close', 'Host': 'download.fht.org', 'User-Agent': 'Python-urllib/3.9'}, encode_chunked=False)
   1284 """Send a complete request to the server."""
-> 1285 self._send_request(method, url, body, headers, encode_chunked)
        method = 'GET'
        url = '/jug/n2v/SEM.zip'
        body = None
        headers = {'Host': 'download.fht.org', 'User-Agent': 'Python-urllib/3.9', 'Connection': 'close'}
        encode_chunked = False
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:1331, in HTTPConnection._send_request(self=<http.client.HTTPSConnection object>, method='GET', url='/jug/n2v/SEM.zip', body=None, headers={'Connection': 'close', 'Host': 'download.fht.org', 'User-Agent': 'Python-urllib/3.9'}, encode_chunked=False)
   1330     body = _encode(body, 'body')
-> 1331 self.endheaders(body, encode_chunked=encode_chunked)
        encode_chunked = False
        body = None
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:1280, in HTTPConnection.endheaders(self=<http.client.HTTPSConnection object>, message_body=None, encode_chunked=False)
   1279     raise CannotSendHeader()
-> 1280 self._send_output(message_body, encode_chunked=encode_chunked)
        message_body = None
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>
        encode_chunked = False

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:1040, in HTTPConnection._send_output(self=<http.client.HTTPSConnection object>, message_body=None, encode_chunked=False)
   1039 del self._buffer[:]
-> 1040 self.send(msg)
        msg = b'GET /jug/n2v/SEM.zip HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: download.fht.org\r\nUser-Agent: Python-urllib/3.9\r\nConnection: close\r\n\r\n'
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>
   1042 if message_body is not None:
   1043
   1044     # create a consistent interface to message_body

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:980, in HTTPConnection.send(self=<http.client.HTTPSConnection object>, data=b'GET /jug/n2v/SEM.zip HTTP/1.1\r\nAccept-Encodi...: Python-urllib/3.9\r\nConnection: close\r\n\r\n')
    979 if self.auto_open:
--> 980     self.connect()
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>
    981 else:

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\http\client.py:1454, in HTTPSConnection.connect(self=<http.client.HTTPSConnection object>)
   1452     server_hostname = self.host
-> 1454 self.sock = self._context.wrap_socket(self.sock,
        self.sock = None
        self = <http.client.HTTPSConnection object at 0x000001E8FD7DB1F0>
        self._context = <ssl.SSLContext object at 0x000001E8F5DB1CC0>
        server_hostname = 'download.fht.org'
   1455                                       server_hostname=server_hostname)

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\ssl.py:501, in SSLContext.wrap_socket(self=<ssl.SSLContext object>, sock=<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True, server_hostname='download.fht.org', session=None)
    495 def wrap_socket(self, sock, server_side=False,
    496                 do_handshake_on_connect=True,
    497                 suppress_ragged_eofs=True,
    498                 server_hostname=None, session=None):
    499     # SSLSocket class handles server_hostname encoding before it calls
    500     # ctx._wrap_socket()
--> 501     return self.sslsocket_class._create(
        self.sslsocket_class = <class 'ssl.SSLSocket'>
        self = <ssl.SSLContext object at 0x000001E8F5DB1CC0>
        sock = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
        server_side = False
        do_handshake_on_connect = True
        suppress_ragged_eofs = True
        server_hostname = 'download.fht.org'
        session = None
    502         sock=sock,
    503         server_side=server_side,
    504         do_handshake_on_connect=do_handshake_on_connect,
    505         suppress_ragged_eofs=suppress_ragged_eofs,
    506         server_hostname=server_hostname,
    507         context=self,
    508         session=session
    509     )

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\ssl.py:1074, in SSLSocket._create(cls=<class 'ssl.SSLSocket'>, sock=<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True, server_hostname='download.fht.org', context=<ssl.SSLContext object>, session=None)
   1073             raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1074         self.do_handshake()
        self = <ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
   1075 except (OSError, ValueError):

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\ssl.py:1343, in SSLSocket.do_handshake(self=<ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>, block=False)
   1342         self.settimeout(None)
-> 1343     self._sslobj.do_handshake()
        self = <ssl.SSLSocket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
        self._sslobj = None
   1344 finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari\_qt\menus\plugins_menu.py:105, in PluginsMenu._add_plugin_actions.<locals>._add_toggle_widget(key=('napari-n2v', 'N2V Demo prediction'), hook_type='dock')
    102     return
    104 if hook_type == 'dock':
--> 105     self._win.add_plugin_dock_widget(*key)
        key = ('napari-n2v', 'N2V Demo prediction')
        self._win = <napari._qt.qt_main_window.Window object at 0x000001E8E2241490>
        self = <napari._qt.menus.plugins_menu.PluginsMenu object at 0x000001E8EA9C24C0>
    106 else:
    107     self._win._add_plugin_function_widget(*key)

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari\_qt\qt_main_window.py:897, in Window.add_plugin_dock_widget(self=<napari._qt.qt_main_window.Window object>, plugin_name='napari-n2v', widget_name='N2V Demo prediction', tabify=False)
    894         wdg = wdg._magic_widget
    895     return dock_widget, wdg
--> 897 wdg = _instantiate_dock_widget(
        Widget = <class 'napari_n2v._predict_widget.DemoPrediction'>
        self = <napari._qt.qt_main_window.Window object at 0x000001E8E2241490>
    898     Widget, cast('Viewer', self._qt_viewer.viewer)
    899 )
    901 # Add dock widget
    902 dock_kwargs.pop('name', None)

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari\_qt\qt_main_window.py:1551, in _instantiate_dock_widget(wdg_cls=<class 'napari_n2v._predict_widget.DemoPrediction'>, viewer=Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoo...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}))
   1546             break
   1547         # cannot look for param.kind == param.VAR_KEYWORD because
   1548         # QWidget allows **kwargs but errs on unknown keyword arguments
   1549
   1550 # instantiate the widget
-> 1551 return wdg_cls(**kwargs)
        kwargs = {'napari_viewer': Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoom=1.0, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(1.0, 1.0), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=2, ndisplay=2, last_used=0, range=((0, 2, 1), (0, 2, 1)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[], help='', status='', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x000001E8DF5D85E0>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})}
        wdg_cls = <class 'napari_n2v._predict_widget.DemoPrediction'>

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari_n2v\_predict_widget.py:332, in DemoPrediction.__init__(self=<napari_n2v._predict_widget.DemoPrediction object>, napari_viewer=Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoo...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}))
    329 ntf.show_info('Downloading data can take a few minutes.')
    331 # get files
--> 332 img, model = demo_files()
    334 # add image to viewer
    335 name = 'Demo image'

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari_n2v\_sample_data.py:110, in demo_files()
    107 def demo_files():
    108     with cwd(get_default_path()):
    109         # load sem validation
--> 110         img = _load_sem()[1][0]
    112         # create models folder if it doesn't already exist
    113         model_path = Path('models', 'trained_sem_N2V2').absolute()

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\site-packages\napari_n2v\_sample_data.py:92, in _load_sem()
     89 img_zip_path = Path(data_path, 'SEM.zip')
     90 if not img_zip_path.exists():
     91     # download and unzip data
---> 92     urllib.request.urlretrieve('https://download.fht.org/jug/n2v/SEM.zip', img_zip_path)
        img_zip_path = WindowsPath('data/sem/SEM.zip')
        urllib.request = <module 'urllib.request' from 'C:\\GBW_MyPrograms\\mambaforge\\envs\\napari-n2v\\lib\\urllib\\request.py'>
     93     with zipfile.ZipFile(img_zip_path, 'r') as zip_ref:
     94         zip_ref.extractall(data_path)

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:239, in urlretrieve(url='https://download.fht.org/jug/n2v/SEM.zip', filename=WindowsPath('data/sem/SEM.zip'), reporthook=None, data=None)
    222 """
    223 Retrieve a URL into a temporary location on disk.
    224
   (...)
    235 data file as well as the resulting HTTPMessage object.
    236 """
    237 url_type, path = _splittype(url)
--> 239 with contextlib.closing(urlopen(url, data)) as fp:
        url = 'https://download.fht.org/jug/n2v/SEM.zip'
        contextlib.closing = <class 'contextlib.closing'>
        data = None
    240     headers = fp.info()
    242     # Just return the local path and the "headers" for file://
    243     # URLs. No sense in performing a copy unless requested.

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:214, in urlopen(url='https://download.fht.org/jug/n2v/SEM.zip', data=None, timeout=<object object>, cafile=None, capath=None, cadefault=False, context=None)
    212 else:
    213     opener = _opener
--> 214 return opener.open(url, data, timeout)
        opener = <urllib.request.OpenerDirector object at 0x000001E8FD7DB100>
        url = 'https://download.fht.org/jug/n2v/SEM.zip'
        data = None
        timeout = <object object at 0x000001E897AFF0A0>

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:517, in OpenerDirector.open(self=<urllib.request.OpenerDirector object>, fullurl='https://download.fht.org/jug/n2v/SEM.zip', data=None, timeout=<object object>)
    514     req = meth(req)
    516 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 517 response = self._open(req, data)
        req = <urllib.request.Request object at 0x000001E8FD7DB3A0>
        data = None
        self = <urllib.request.OpenerDirector object at 0x000001E8FD7DB100>
    519 # post-process response
    520 meth_name = protocol+"_response"

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:534, in OpenerDirector._open(self=<urllib.request.OpenerDirector object>, req=<urllib.request.Request object>, data=None)
    531     return result
    533 protocol = req.type
--> 534 result = self._call_chain(self.handle_open, protocol, protocol +
        result = None
        protocol = 'https'
        self.handle_open = {'unknown': [<urllib.request.UnknownHandler object at 0x000001E8FD7EFA00>], 'http': [<urllib.request.HTTPHandler object at 0x000001E8FD7EFA90>], 'ftp': [<urllib.request.FTPHandler object at 0x000001E8FD7EFC70>], 'file': [<urllib.request.FileHandler object at 0x000001E8FD7EFB20>], 'data': [<urllib.request.DataHandler object at 0x000001E8FD7EFC40>], 'https': [<urllib.request.HTTPSHandler object at 0x000001E8FD7EFCD0>]}
        protocol +
                                  '_open' = 'https_open'
        self = <urllib.request.OpenerDirector object at 0x000001E8FD7DB100>
        req = <urllib.request.Request object at 0x000001E8FD7DB3A0>
    535                           '_open', req)
    536 if result:
    537     return result

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:494, in OpenerDirector._call_chain(self=<urllib.request.OpenerDirector object>, chain={'data': [<urllib.request.DataHandler object>], 'file': [<urllib.request.FileHandler object>], 'ftp': [<urllib.request.FTPHandler object>], 'http': [<urllib.request.HTTPHandler object>], 'https': [<urllib.request.HTTPSHandler object>], 'unknown': [<urllib.request.UnknownHandler object>]}, kind='https', meth_name='https_open', *args=(<urllib.request.Request object>,))
    492 for handler in handlers:
    493     func = getattr(handler, meth_name)
--> 494     result = func(*args)
        func = <bound method HTTPSHandler.https_open of <urllib.request.HTTPSHandler object at 0x000001E8FD7EFCD0>>
        args = (<urllib.request.Request object at 0x000001E8FD7DB3A0>,)
    495     if result is not None:
    496         return result

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:1389, in HTTPSHandler.https_open(self=<urllib.request.HTTPSHandler object>, req=<urllib.request.Request object>)
   1388 def https_open(self, req):
-> 1389     return self.do_open(http.client.HTTPSConnection, req,
        req = <urllib.request.Request object at 0x000001E8FD7DB3A0>
        self = <urllib.request.HTTPSHandler object at 0x000001E8FD7EFCD0>
        http.client = <module 'http.client' from 'C:\\GBW_MyPrograms\\mambaforge\\envs\\napari-n2v\\lib\\http\\client.py'>
        self._context = None
        self._check_hostname = None
   1390         context=self._context, check_hostname=self._check_hostname)

File C:\GBW_MyPrograms\mambaforge\envs\napari-n2v\lib\urllib\request.py:1349, in AbstractHTTPHandler.do_open(self=<urllib.request.HTTPSHandler object>, http_class=<class 'http.client.HTTPSConnection'>, req=<urllib.request.Request object>, **http_conn_args={'check_hostname': None, 'context': None})
   1346         h.request(req.get_method(), req.selector, req.data, headers,
   1347                   encode_chunked=req.has_header('Transfer-encoding'))
   1348     except OSError as err: # timeout error
-> 1349         raise URLError(err)
   1350     r = h.getresponse()
   1351 except:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)>
@jdeschamps
Copy link
Member

What happens if you try to download the file by using the following link: https://download.fht.org/jug/n2v/SEM.zip ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants