takluyver / nbopen

Open a Jupyter notebook in the best available server
BSD 3-Clause "New" or "Revised" License
304 stars 58 forks source link

ImportError: DLL load failed while importing error: The specified module could not be found. #76

Open fmamitrotta opened 3 years ago

fmamitrotta commented 3 years ago

I wanted to be able to open .ipynb files with a double click, so I installed nbopen as indicated by this answer on stackoverflow. Furthermore, I needed to set a specific conda environment as kernel of the notebook, so I followed the steps indicated here . I also added the following paths to my PATH environment variable: C:\Users\qa21944\Anaconda3 C:\Users\qa21944\Anaconda3\Scripts C:\Users\qa21944\Anaconda3\Library\bin C:\Users\qa21944\Anaconda3\Library\mingw-w64\bin

Unfortunately when I try to open a notebook from the pyNastran package with a double click, the kernel does not connect to the conda environment I need. In the nbopen window I see the following error:

Starting new server
[W 2021-10-19 15:24:01.263 LabApp] 'file_to_run' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-10-19 15:24:01.263 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-10-19 15:24:01.263 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-10-19 15:24:01.263 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-10-19 15:24:01.263 LabApp] JupyterLab extension loaded from c:\users\qa21944\anaconda3\lib\site-packages\jupyterlab
[I 2021-10-19 15:24:01.263 LabApp] JupyterLab application directory is C:\Users\qa21944\Anaconda3\share\jupyter\lab
[I 15:24:01.279 NotebookApp] Serving notebooks from local directory: C:\Users\qa21944
[I 15:24:01.279 NotebookApp] Jupyter Notebook 6.4.3 is running at:
[I 15:24:01.279 NotebookApp] http://localhost:8888/?token=3ca66cad036fd1cc740745ec5cf7998b1d49086785237b38
[I 15:24:01.279 NotebookApp]  or http://127.0.0.1:8888/?token=3ca66cad036fd1cc740745ec5cf7998b1d49086785237b38
[I 15:24:01.279 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:24:01.310 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/qa21944/AppData/Roaming/jupyter/runtime/nbserver-6592-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=3ca66cad036fd1cc740745ec5cf7998b1d49086785237b38
     or http://127.0.0.1:8888/?token=3ca66cad036fd1cc740745ec5cf7998b1d49086785237b38
c:\users\qa21944\anaconda3\lib\json\encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
  return _iterencode(o, 0)
Exception in callback <TaskWakeupMethWrapper object at 0x000002C083D02130>(<Future finis...491"\r\n\r\n'>)
handle: <Handle <TaskWakeupMethWrapper object at 0x000002C083D02130>(<Future finis...491"\r\n\r\n'>)>
Traceback (most recent call last):
  File "c:\users\qa21944\anaconda3\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-18' coro=<HTTP1ServerConnection._server_request_loop() running at c:\users\qa21944\anaconda3\lib\site-packages\tornado\http1connection.py:823> wait_for=<Future finished result=b'GET /api/co...2491"\r\n\r\n'> cb=[IOLoop.add_future.<locals>.<lambda>() at c:\users\qa21944\anaconda3\lib\site-packages\tornado\ioloop.py:688]> while another task <Task pending name='Task-2' coro=<KernelManager._async_start_kernel() running at c:\users\qa21944\anaconda3\lib\site-packages\jupyter_client\manager.py:335>> is being executed.
[I 15:24:12.809 NotebookApp] Kernel started: 7179dd0a-8c36-4fae-8fed-e653486345c3, name: learning-pynastran
Traceback (most recent call last):
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\__init__.py", line 50, in <module>
    from zmq import backend
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.
[I 15:24:15.819 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\__init__.py", line 50, in <module>
    from zmq import backend
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\Users\qa21944\Anaconda3\envs\learning-pynastran\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.

What I cannot understand is the fact that if I open the notebook with PyCharm, everything runs smoothly. What could be the problem?

takluyver commented 3 years ago

I would guess that something about the environment (like environment variables or the CWD) is different when you double-click a file from when you launch the notebook in Jupyter. I don't really know how to figure out what that difference is, though - sorry.