Muchdecal
Muchdecal

Reputation: 177

can't work on virtual environment with jupyter

I wanted to work on virtual environment with jupyterlab.

But when I tried pipenv and ipykernel to create a new kernel for python, the code says ModuleNotFoundError: No module named 'zmq.utils'.

I followed the instruction from this post.

In conda shell, I tried to download pipenv and ipykernel.

After I saw No module named 'zmq.utils' error, I tried to uninstall and reinstall zmq module. But it still gave the same error message.

Here is the code:

with pipenv installed

pipenv install ipykernel
pipenv shell

python -m ipykernel install --user --name=my-virtualenv-name

Then I got the error message that ModuleNotFoundError: No module named 'zmq.utils'

Here is the full description:

Traceback (most recent call last):
  File "c:\users\kevin\anaconda31\Lib\runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "c:\users\kevin\anaconda31\Lib\runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "c:\users\kevin\anaconda31\Lib\runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\jupyter_client\connect.py", line 23, in <module>
    import zmq
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\zmq\__init__.py", line 49, in <module>
    from zmq import sugar
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\zmq\sugar\__init__.py", line 7, in <module>
    from zmq.sugar import (
  File "C:\Users\Kevin\.virtualenvs\Kevin-WjGwMqCZ\lib\site-packages\zmq\sugar\constants.py", line 8, in <module>
    from zmq.utils.constant_names import (
ModuleNotFoundError: No module named 'zmq.utils'

Upvotes: 0

Views: 614

Answers (1)

Muchdecal
Muchdecal

Reputation: 177

I still don't know what's the problem. But I solved it by deleting my virtual environment file and reinstall it again.

Here are steps I took:

I found the .virtualenv file that was automatically created in my path and deleted the virtual environment in the file.

Next, I reinstalled ipykernel

pipenv install ipykernel

Then I run

pipenv shell

in command, which created a new virtual environment.

and lastly I created another kernel using:

python -m ipykernel install --user --name=my-virtualenv-name

This time it didn't show any error message

Upvotes: 1

Related Questions