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

problem when installing with jupyter notebook #242

Open
DanielaPamplona opened this issue Jan 23, 2024 · 7 comments
Open

problem when installing with jupyter notebook #242

DanielaPamplona opened this issue Jan 23, 2024 · 7 comments

Comments

@DanielaPamplona
Copy link

I created a new env. in conda, installed plenoptic and jupyter notebook. When I tried to launch the notebook I got an error and it did not launch. I repeated the process without installing plenoptic and it worked.

Error below (copy-paste):


(p2) daniela@Vietnam:~$ jupyter notebook
Traceback (most recent call last):
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/requests/compat.py", line 11, in
import chardet
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/daniela/anaconda3/envs/p2/bin/jupyter-notebook", line 7, in
from notebook.app import main
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/notebook/app.py", line 20, in
from jupyterlab.commands import ( # type:ignore[import-untyped]
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab/init.py", line 8, in
from .handlers.announcements import (
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab/handlers/announcements.py", line 15, in
from jupyterlab_server.translation_utils import translator
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab_server/init.py", line 6, in
from .app import LabServerApp
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab_server/app.py", line 15, in
from .handlers import LabConfig, add_handlers
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab_server/handlers.py", line 21, in
from .listings_handler import ListingsHandler, fetch_listings
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/jupyterlab_server/listings_handler.py", line 10, in
import requests
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/requests/init.py", line 45, in
from .exceptions import RequestsDependencyWarning
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/requests/exceptions.py", line 9, in
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/requests/compat.py", line 13, in
import charset_normalizer as chardet
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/charset_normalizer/init.py", line 23, in
from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
File "/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/charset_normalizer/api.py", line 10, in
from charset_normalizer.md import mess_ratio
File "charset_normalizer/md.py", line 5, in
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (/home/daniela/anaconda3/envs/p2/lib/python3.9/site-packages/charset_normalizer/constant.py)


System (please complete the following information):

  • Ubuntu
  • Python version (as in the installation guide)
  • Pytorch version (as in the installation guide)
  • Plenoptic version (as in the installation guide)
@billbrod
Copy link
Collaborator

Huh, I have never seen that kind of error. I can't reproduce this on my (Fedora) machine using micromamba, where I did the following:

micromamba create -n plen_nb 'python==3.9' -c conda-forge
# install from local copy
cd plenoptic/
pip install .
micromamba install -c conda-forge jupyterlab ipywidgets torchvision
jupyter lab

and that works. My understanding is that jupyter is encouraging everyone to go through jupyter lab now, not notebook, but running micromamba install -c conda-forge notebook after the above and then jupyter notebook works as well.

I'm not quite sure how to best debug this -- I'm not sure why there would be a chardet problem, which looks like it's a requests dependency, so maybe there's an incompatibility in the requests versions that end up getting used between the two? If so, then this is probably what I get for encouraging people to use conda for jupyter and pip for plenoptic, as you and @NickleDave pointed out.

A couple of possible ideas:

  • Can you paste the exact sequence of commands you ran checking the version of requests after each of the install commands?
  • If you try installing jupyterlab rather than notebook, as I did above, does that work?
  • If you install jupyter (try both notebook and lab) and then plenoptic, do you get the same issues?

@DanielaPamplona
Copy link
Author

Hi,
The commands were:


conda create --name p2 pip python=3.9
conda activate p2
pip install plenoptic
conda install jupyter notebook
jupyter notebook

If jupyter encourages to use lab instead of notebook, then I think that you can just write a statement in the installation saying that it must be installed lab. However, this solution must be discussed with the editor.

I also think that this might result from mixing pip and conda.

@billbrod
Copy link
Collaborator

Okay, I'm still unable to reproduce this error following these steps. I'm using conda-forge as the only channel, so maybe that's the difference?

If you have time and can check the bullet points I wrote above, as well as what channels you're conda is using, that might help us get more specific.

But I think for now we assume it's a mixing of pip/conda issue (see related #104). I don't think it won't work with notebook, because I'm able to get it working with notebook locally. but lab might make it easier to get a working environment(?). Not really sure.

@DanielaPamplona
Copy link
Author

So, I checked and if I install first the notebook and then plenoptic there is no problem. There is also no problem when installing with jupyter lab. So, I would say, we just check this again after solving the pip issue.

@sneakers-the-rat
Copy link

I was able to reproduce the issue (on a mac, if that matters). It's also not specific to jupyter (or plenoptic, for that matter) - if one tries to import requests after doing this, you get the same error.

This looks like a requests problem initially:
psf/requests#6384

but it turns out to be a jupyter problem.

requests tries to import either chardet or charset_normalizer:
https://github.com/psf/requests/blob/147c8511ddbfa5e8f71bbf5c18ede0c4ceb3bba4/requests/compat.py#L10-L15

they require >=2,<4: https://github.com/psf/requests/blob/147c8511ddbfa5e8f71bbf5c18ede0c4ceb3bba4/setup.cfg#L8

but the version that is installed is 2.0.4 - notably older than the current 3.3.2.

Inspecting the jupyter and notebook conda packages, they both pin charset-normalizer 2.0.4 (download the .tar.gz's from conda (anaconda), uncompress, see info > about.json).

uninstalling requests and reinstalling jupyter or notebook from pip resolved the problem.

It also seems to be just a problem with the jupyter and notebook packages in the default anaconda package source. using conda-forge also resolves the problem (conda install -c conda-forge jupyter notebook)

So I think adding the -c conda-forge resolves this

@billbrod
Copy link
Collaborator

@DanielaPamplona Can you try following our new installation instructions? In particular, the conda instructions.

@DanielaPamplona
Copy link
Author

DanielaPamplona commented Aug 23, 2024 via email

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

3 participants