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

Python 3.12 not supported #538

Closed
JasonWeill opened this issue Dec 21, 2023 · 28 comments · Fixed by #898
Closed

Python 3.12 not supported #538

JasonWeill opened this issue Dec 21, 2023 · 28 comments · Fixed by #898
Labels
bug Something isn't working dependency:faiss-cpu Issues pertaining to `faiss-cpu`

Comments

@JasonWeill
Copy link
Collaborator

Description

Attempting to install Jupyter AI on Python 3.12 is not supported, even though our recipe on conda-forge merely stipulates python >=3.8.

The following error occurs when running pip install jupyter_ai with Python 3.12 on macOS 13.6.3 on an Apple Silicon processor:

...
Using cached yarl-1.9.4-cp312-cp312-macosx_11_0_arm64.whl (79 kB)
Building wheels for collected packages: faiss-cpu
  Building wheel for faiss-cpu (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for faiss-cpu (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building 'faiss._swigfaiss' extension
      swigging faiss/faiss/python/swigfaiss.i to faiss/faiss/python/swigfaiss_wrap.cpp
      swig -python -c++ -Doverride= -I/usr/local/include -Ifaiss -doxygen -module swigfaiss -o faiss/faiss/python/swigfaiss_wrap.cpp faiss/faiss/python/swigfaiss.i
      Traceback (most recent call last):
        File "/opt/miniconda3/envs/jupyter-ai-jl4-pip/bin/swig", line 5, in <module>
          from swig import swig
      ModuleNotFoundError: No module named 'swig'
      error: command '/opt/miniconda3/envs/jupyter-ai-jl4-pip/bin/swig' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for faiss-cpu
Failed to build faiss-cpu
ERROR: Could not build wheels for faiss-cpu, which is required to install pyproject.toml-based projects

See also kyamagu/faiss-wheels#87 for the lack of Python 3.12 wheels for faiss-cpu.

@JasonWeill JasonWeill added the bug Something isn't working label Dec 21, 2023
@OleksandrKucherenko
Copy link

OleksandrKucherenko commented Jan 20, 2024

# CPU-only version
$ conda install -c pytorch/label/nightly faiss-cpu

# GPU(+CPU) version
$ conda install -c pytorch/label/nightly -c nvidia faiss-gpu=1.7.4

then try to install again

p.s. 2 days ago were merged changes required for successful run on v3.12 python.

p.p.s. for Apple Silicon should be used CPU only version

@OleksandrKucherenko
Copy link

Install with virtual environment, exec it in project folder, not in your HOME dir

pip install virtualenv
python -m venv myenv
source myenv/bin/activate

pip install jupyter_ai
deactivate

@JasonWeill
Copy link
Collaborator Author

I created a new Conda environment with Python 3.12 on an Apple Silicon Mac, installed JupyterLab 4.0.11, and I tried to run ./scripts/install.sh from my local Jupyter AI repository's root. Although it fetched the faiss-cpu 1.7.4 wheel, I got an error during the install process. Partial log:

> @jupyter-ai/core:dev-install

@jupyter-ai/core: yarn run v1.22.19
$ pip install -e ".[dev,all,test]" && jupyter labextension develop . --overwrite && jupyter server extension enable jupyter_ai
@jupyter-ai/core: Obtaining file:///Users/jweill/git/jupyter-ai/packages/jupyter-ai
@jupyter-ai/core:   Installing build dependencies: started
@jupyter-ai/core:   Installing build dependencies: finished with status 'done'
@jupyter-ai/core:   Checking if build backend supports build_editable: started
@jupyter-ai/core:   Checking if build backend supports build_editable: finished with status 'done'
@jupyter-ai/core:   Getting requirements to build editable: started
@jupyter-ai/core:   Getting requirements to build editable: finished with status 'done'
@jupyter-ai/core:   Installing backend dependencies: started
@jupyter-ai/core:   Installing backend dependencies: finished with status 'done'
@jupyter-ai/core:   Preparing editable metadata (pyproject.toml): started
@jupyter-ai/core:   Preparing editable metadata (pyproject.toml): finished with status 'done'

…

@jupyter-ai/core: Collecting faiss-cpu (from jupyter_ai==2.10.0b0)
@jupyter-ai/core:   Downloading faiss-cpu-1.7.4.tar.gz (57 kB)
@jupyter-ai/core:      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/57.4 kB ? eta -:--:--
                       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.4/57.4 kB 6.1 MB/s eta 0:00:00
@jupyter-ai/core:   Installing build dependencies: started
@jupyter-ai/core:   Installing build dependencies: finished with status 'done'
@jupyter-ai/core:   Getting requirements to build wheel: started
@jupyter-ai/core:   Getting requirements to build wheel: finished with status 'done'
@jupyter-ai/core:   Preparing metadata (pyproject.toml): started
@jupyter-ai/core:   Preparing metadata (pyproject.toml): finished with status 'done'

…

@jupyter-ai/core: Building wheels for collected packages: jupyter_ai, faiss-cpu, colored
@jupyter-ai/core:   Building editable for jupyter_ai (pyproject.toml): started
@jupyter-ai/core:   Building editable for jupyter_ai (pyproject.toml): finished with status 'done'
@jupyter-ai/core:   Created wheel for jupyter_ai: filename=jupyter_ai-2.10.0b0-py3-none-any.whl size=6047506 sha256=5dc674fd5c8f69797bf59b8aafda385612ca7acb3ce1410d098d16d23ec65c32
@jupyter-ai/core:   Stored in directory: /private/var/folders/md/x69whq_524q4kb6r0gnq3df40000gr/T/pip-ephem-wheel-cache-29jz42ea/wheels/37/f0/07/c80035cdc0507bfc2805314c907280b36cec99fd0028111e67
@jupyter-ai/core:   Building wheel for faiss-cpu (pyproject.toml): started
@jupyter-ai/core:   Building wheel for faiss-cpu (pyproject.toml): finished with status 'error'
@jupyter-ai/core:   error: subprocess-exited-with-error
@jupyter-ai/core:   
@jupyter-ai/core:   × Building wheel for faiss-cpu (pyproject.toml) did not run successfully.
@jupyter-ai/core:   │ exit code: 1
@jupyter-ai/core:   ╰─> [8 lines of output]
@jupyter-ai/core:       running bdist_wheel
@jupyter-ai/core:       running build
@jupyter-ai/core:       running build_py
@jupyter-ai/core:       running build_ext
@jupyter-ai/core:       building 'faiss._swigfaiss' extension
@jupyter-ai/core:       swigging faiss/faiss/python/swigfaiss.i to faiss/faiss/python/swigfaiss_wrap.cpp
@jupyter-ai/core:       swig -python -c++ -Doverride= -I/usr/local/include -Ifaiss -doxygen -module swigfaiss -o faiss/faiss/python/swigfaiss_wrap.cpp faiss/faiss/python/swigfaiss.i
@jupyter-ai/core:       error: command 'swig' failed: No such file or directory
@jupyter-ai/core:       [end of output]
@jupyter-ai/core:   
@jupyter-ai/core:   note: This error originates from a subprocess, and is likely not a problem with pip.
@jupyter-ai/core:   ERROR: Failed building wheel for faiss-cpu
@jupyter-ai/core:   Building wheel for colored (setup.py): started
@jupyter-ai/core:   Building wheel for colored (setup.py): finished with status 'done'
@jupyter-ai/core:   Created wheel for colored: filename=colored-1.4.4-py3-none-any.whl size=14249 sha256=f37a7704023a420b0a10c9896470671d2a0aea76e0dd657ba6f55054f7c54463
@jupyter-ai/core:   Stored in directory: /Users/jweill/Library/Caches/pip/wheels/7e/5d/d5/b488a46de10f44dcf9d525a2051d51f45474e8dee6ab3da46b
@jupyter-ai/core: Successfully built jupyter_ai colored
@jupyter-ai/core: Failed to build faiss-cpu
@jupyter-ai/core: ERROR: Could not build wheels for faiss-cpu, which is required to install pyproject.toml-based projects
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 ——————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Running target dev-install for 2 projects failed

@JasonWeill
Copy link
Collaborator Author

@OleksandrKucherenko Are you using Apple Silicon locally? Were you able to install using a wheel that works with these processors? kyamagu/faiss-wheels#87 remains open.

@adriens
Copy link
Contributor

adriens commented Jan 25, 2024

✔️ Reproduced on latest Kaggle env, so I switched back in time (2024-01-11) so the following runtime is 🆗

image

sys.version_info(major=3, minor=10, micro=12, releaselevel='final', serial=0)

@JasonWeill
Copy link
Collaborator Author

kyamagu/faiss-wheels#87 was completed last week, so once its new version is published, we should be able to add Python 3.12 support.

@adriens
Copy link
Contributor

adriens commented Feb 22, 2024

Once the issue closed i'll upgrade the notebook and let you know here 👍

@dlqqq
Copy link
Member

dlqqq commented Feb 27, 2024

Progress is being made on this issue.
kyamagu/faiss-wheels#88 was merged, meaning that Python 3.12 wheels will be distributed for future faiss releases.

faiss will likely have a release in two weeks: facebookresearch/faiss#3263 (comment). This means that in two weeks' time, we should be able to bump our faiss dependency and allow for Python 3.12. 🎉

Link to upstream issue: kyamagu/faiss-wheels#87

@adriens
Copy link
Contributor

adriens commented Feb 27, 2024

Yup, and I also saw the releaseNote of the latest Jupyter: it rocks 😎

@JIZUSHANBOJUE
Copy link

JIZUSHANBOJUE commented Mar 10, 2024

  1. pip install jupyter_ai_magic
  2. pip install jupyter_ai

If it's still fail, try to install vs_BuildTools.exe first.
Actually, you can use jupyter_ai_magic instead of jupyter_ai.

@adriens
Copy link
Contributor

adriens commented Mar 10, 2024

Thanks for feedbacks @JIZUSHANBOJUE , I'm giving it a try ⚡

@adriens
Copy link
Contributor

adriens commented Mar 10, 2024

⏳ Test in progress

@adriens
Copy link
Contributor

adriens commented Mar 10, 2024

It's all 🙆‍♂️ I've switcher to latest available Kaggle runtime 3.12, see 🪄 Jupyter-AI magic

🙏 @JIZUSHANBOJUE for the tip
image

@fperez
Copy link

fperez commented Mar 18, 2024

Quick ping - if I'm reading this correctly, faiss 1.8.0 is now out with the required updates. Would it be possible to push up a release here so we can deploy in 3.12 environments that are conda/mamba-managed? No worries if something else is holding things up, but if not, I'd love to have it more widely available :) Thanks team for the great work!

@adriens
Copy link
Contributor

adriens commented Mar 18, 2024

ready to upgrade my test env 😎

@fperez
Copy link

fperez commented Apr 16, 2024

Hi folks, checking in - the conda/mamba install under a 3.12 environment still fails to resolve... If I read the error log correctly, the problem is a pin on tiktoken < 0.4.0, which is incompatible with py3.12...

I tested this in a freshly created conda/mamba environment that only had py3.12 in it, and nothing else, to be sure the incompatibilities weren't being triggered by any other package in my (large) regular env.

Happy to provide further testing if useful, this was all on an intel Mac with conda-forge packages and using mamba as the client.

@ltalirz
Copy link

ltalirz commented May 9, 2024

The dependency on tiktoken was removed, but for me it now chokes on faiss-cpu

environment.yml

channels:
- conda-forge
dependencies:
- python ==3.12  # when removing this pin, it completes fine with python 3.11.9
- jupyter-ai >=2.14.1

Result

$ mamba env create -f environment.yml --name jupyter-ai
conda-forge/osx-64                                          Using cache
conda-forge/noarch                                          Using cache
pkgs/main/osx-64                                              No change
pkgs/main/noarch                                              No change
pkgs/r/osx-64                                                 No change
pkgs/r/noarch                                                 No change


Looking for: ['python==3.12', "jupyter-ai[version='>=2.14.1']"]


Encountered problems while solving:
  - package jupyter-ai-2.14.1-pyhd8ed1ab_0 requires faiss-cpu, but none of the providers can be installed

@fperez
Copy link

fperez commented May 9, 2024

Yup, can confirm - the full log I get for a similar request is:

The following package could not be installed
└─ jupyter-ai is installable and it requires
   └─ faiss-cpu, which requires
      └─ faiss [1.7.2 *_cpu|1.7.3 *_cpu|1.7.4 *_cpu] with the potential options
         ├─ faiss [1.7.2|1.7.3|1.7.4] would require
         │  └─ python >=3.10,<3.11.0a0 , which can be installed;
         ├─ faiss [1.7.2|1.7.3|1.7.4] would require
         │  └─ python >=3.11,<3.12.0a0 , which can be installed;
         ├─ faiss [1.7.2|1.7.3|1.7.4] would require
         │  └─ python >=3.8,<3.9.0a0 , which can be installed;
         └─ faiss [1.7.2|1.7.3|1.7.4] would require
            └─ python >=3.9,<3.10.0a0 , which can be installed.

Please let us know if there's anything we could do to help, thanks for all the great work on this project!

@dlqqq
Copy link
Member

dlqqq commented May 9, 2024

Unfortunately the latest release of faiss-cpu that supports Python 3.12 is not present on Conda Forge. It seems the feedstock has been unmaintained for some time: https://github.com/conda-forge/faiss-split-feedstock

Furthermore, there doesn't seem to be a way to specify a dependency to be installed only via pip: conda/conda-build#548

@adriens
Copy link
Contributor

adriens commented May 9, 2024

Thanks a lot guys for the followup and giving up 🙏

@EwoutH
Copy link

EwoutH commented Jun 6, 2024

I would love Python 3.12 support. What's the current status?

@dlqqq
Copy link
Member

dlqqq commented Jul 15, 2024

@EwoutH @fperez @ltalirz @adriens

As of Jupyter AI v2.19.0,

  • Python 3.12 should be fully supported if Jupyter AI is installed via pip, but
  • Python 3.12 is not supported if Jupyter AI is installed via conda.

This pain point doesn't seem to be resolving itself anytime soon, so right now I'm exploring if I can manually define the jupyter-ai Conda recipe to install faiss-cpu via pip instead of conda in a post-install script. If this works, then Python 3.12 should be supported regardless of whether Jupyter AI is installed via pip or conda, then the README can be updated and this issue can be closed.

Thank you all for your patience!

PR link: conda-forge/jupyter-ai-feedstock#36

@fperez
Copy link

fperez commented Jul 16, 2024

Thanks for the update @dlqqq! Unfortunate to see that issue with faiss, but I appreciate you looking for a workaround.

@dlqqq
Copy link
Member

dlqqq commented Jul 16, 2024

I've updated the Jupyter AI feedstock to install faiss-cpu<=1.8.0 via pip instead of conda.

Jupyter AI v2.19.0 now supports Python 3.12 when installed from either PyPI or Conda Forge! #898 adds Python 3.12 support to the documentation and will close this issue once merged. Thank you all for pushing on this issue! 🤗

@fperez
Copy link

fperez commented Jul 16, 2024

Wonderful, just installed it in my 3.12 env and it went smoothly! I will report if I see any issues. Thanks again!

@adriens
Copy link
Contributor

adriens commented Jul 18, 2024

Hi guys, sorry for late feedback. I'm running it right now ⚡

@adriens
Copy link
Contributor

adriens commented Jul 19, 2024

🙆‍♂️ 👌 🙏 👏

@EwoutH
Copy link

EwoutH commented Jul 20, 2024

Awesome! Since Python 3.13 is already in beta, time to start working on the next one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependency:faiss-cpu Issues pertaining to `faiss-cpu`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants