neo4j/neo4j-python-driver

Missing dependency in `pip install neo4j`

tla opened this issue · 4 comments

tla commented

Bug Report

Pip fails to install neo4j:

Collecting neo4j
  Using cached neo4j-5.3.0.tar.gz (157 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Error in sitecustomize; set PYTHONVERBOSE for traceback:
      AssertionError:
      Traceback (most recent call last):
        File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/opt/homebrew/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/opt/homebrew/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/opt/homebrew/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 29, in <module>
      ModuleNotFoundError: No module named 'tomlkit'
      [end of output]

This is easily resolved by installing the tomlkit package, but the package dependencies evidently need to be updated.

My Environment

Python Version: Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]
Driver Version: 5.3.0
Server Version and Edition: Neo4J Desktop, various versions
Operating System: MacOS 13.0.1

Thanks for reporting this.

A little context: tomlkit is not a dependency of the driver itself but is only used for the setup process.

What version of pip are you using? (run pip -V, for example)

Does upgrading your pip (e.g., pip install -U pip) resolve the issue?

Pip should be installing tomlkit as instructed in the project.toml before handing off the setup process to setuptools. I'm puzzled as to why it doesn't.

tla commented

No problem - I'm not sure how more useful I can be, since I did resolve the issue by installing tomlkit anyway, but:

tla@Taras-MacBook-Pro-2 scratch % pip -V
pip 22.3.1 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)
tla@Taras-MacBook-Pro-2 scratch % pip install -U pip
Requirement already satisfied: pip in /opt/homebrew/lib/python3.10/site-packages (22.3.1)

I don't know if this is relevant, but: while I can reproduce it on another computer that didn't yet have the neo4j package installed (and is also running pip 22.3.1), I can't reproduce it in a new venv once I have installed tomlkit globally.

Hm 🤔 I can't reproduce this error locally. Just to double check: what command did you run when this failed? Simply pip install neo4j? And was it outside of a virtualenv? If it was inside a virtualenv, please let me know if you created it with venv (e.g., python -m venv ... or with virtualenv (e.g., python -m virtualenv ...).

I had a colleague of mine who's on mac 13.0.1 as well try to reproduce this. He first couldn't but eventually manage to. Here's what he wrote:

I ran python3 -m pip install --force --no-cache-dir neo4j once and it installs 5.2.1 [instead of 5.3.0 with a warning about metadata]. Then I ran python3 -m pip install pip and then python3 -m pip install --force --no-cache-dir neo4j, this makes the command fail with the same reported error. pip3 install and pip install just worked fin installing the correct versions.

So should future mac users run across this, try installing the dependency using pip directly (instead of python -m pip).