Error while installing jupyterlab with poetry

Question:

I can’t isntall JupyterLab with poetry. I keep getting this error. I’ve tried deleting cache by:

 rm -rf ~/Library/Caches/pypoetry/artifacts/*

and

poetry cache clear pypi --all  

but I keep getting the following error:

$ poetry add --group dev jupyterlab    
                                                                             
Using version ^3.6.1 for jupyterlab

Updating dependencies
Resolving dependencies... (2.6s)

Package operations: 12 installs, 0 updates, 0 removals

  • Installing y-py (0.5.5): Failed

  CalledProcessError

  Command '['/Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9/bin/python', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9', '--no-deps', '/Users/mc/Library/Caches/pypoetry/artifacts/be/5d/9c/38ed00c38e66f11b3f1295c0b4fa2565c954b8e0c8d63deac26e996efa/y_py-0.5.5.tar.gz']' returned non-zero exit status 1.

  at /opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py:528 in run
       524│             # We don't call process.wait() as .__exit__ does that for us.
       525│             raise
       526│         retcode = process.poll()
       527│         if check and retcode:
    →  528│             raise CalledProcessError(retcode, process.args,
       529│                                      output=stdout, stderr=stderr)
       530│     return CompletedProcess(process.args, retcode, stdout, stderr)
       531│ 
       532│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['/Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9/bin/python', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9', '--no-deps', '/Users/mc/Library/Caches/pypoetry/artifacts/be/5d/9c/38ed00c38e66f11b3f1295c0b4fa2565c954b8e0c8d63deac26e996efa/y_py-0.5.5.tar.gz'] errored with the following return code 1, and output: 
  Processing /Users/mc/Library/Caches/pypoetry/artifacts/be/5d/9c/38ed00c38e66f11b3f1295c0b4fa2565c954b8e0c8d63deac26e996efa/y_py-0.5.5.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'error'
    error: subprocess-exited-with-error
    
    × Preparing metadata (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [6 lines of output]
        
        Cargo, the Rust package manager, is not installed or is not on PATH.
        This package requires Rust and Cargo to compile extensions. Install it through
        the system's package manager or via https://rustup.rs/
        
        Checking for Rust toolchain....
        [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: metadata-generation-failed
  
  × Encountered error while generating package metadata.
  ╰─> See above for output.
  
  note: This is an issue with the package mentioned above, not pip.
  hint: See above for details.
  

  at ~/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/utils/env.py:1540 in _run
      1536│                 output = subprocess.check_output(
      1537│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
      1538│                 )
      1539│         except CalledProcessError as e:
    → 1540│             raise EnvCommandError(e, input=input_)
      1541│ 
      1542│         return decode(output)
      1543│ 
      1544│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

The following error occurred when trying to handle this error:


  PoetryException

  Failed to install /Users/mc/Library/Caches/pypoetry/artifacts/be/5d/9c/38ed00c38e66f11b3f1295c0b4fa2565c954b8e0c8d63deac26e996efa/y_py-0.5.5.tar.gz

  at ~/Library/Application Support/pypoetry/venv/lib/python3.9/site-packages/poetry/utils/pip.py:58 in pip_install
       54│ 
       55│     try:
       56│         return environment.run_pip(*args)
       57│     except EnvCommandError as e:
    →  58│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
       59│ 

Env info

$ poetry env info                                                                                                           

Virtualenv
Python:         3.9.16
Implementation: CPython
Path:           /Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9
Executable:     /Users/mc/Library/Caches/pypoetry/virtualenvs/showcase-project-lis5iaDt-py3.9/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.9.16
Path:       /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9
Executable: /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/bin/python3.9

How can I solve this issue with y_py package?
Do I really need to install rust to use jupyterlab with poetry as stated in the message?

Asked By: mCs

||

Answers:

You need to install rust and cargo locally to run this

rustup is an installer for
the systems programming language

After that try running

poetry add --group dev jupyterlab     

or

poetry add --group dev jupyterlab==version 

Try installing a lower version to see if it works. jupyterlab package has dependencies that require compilation, and Rust and Cargo are needed to build those dependencies. It attempts to install y-py, can you try installing python from conda-forge and then install y-py. may be that helps and poetry works without rust & cargo

Answered By: Bijendra

It seems that there is a bug with jupyterLab latest version

https://github.com/jupyterlab/jupyterlab/issues/12436

Just install jupyterlab older version:

poetry add --group dev jupyterlab==3.5.2

Answered By: mCs