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

ImportError: cannot import name 'errors' from 'setuptools' (/opt/render/project/src/.venv/lib/python3.7/site-packages/setuptools/__init__.py) ImportError: cannot import name 'errors' from 'setuptools' (/opt/render/project/src/.venv/lib/python3.7/site-packages/setuptools/__init__.py) #4199

Open
StarSupreme opened this issue Feb 1, 2024 · 1 comment
Labels
Needs Latest Version Test A test using the latest version of setuptools is needed before further investigation Needs Simplified Reproducer A simplified (ideally minimal) reproducer needs to be provided so that investigation may proceed

Comments

@StarSupreme
Copy link

setuptools version

setuptools==59.8.0

Python version

Python 3.7

OS

Using Render

Additional environment information

This only happens in Render.

Description

I'm trying to deploy a flask app on the web using render. I need python 3.7, because that is the only version supported by one of my necessary libraries. Anyways, when it gets to grpcio, it gives this error:-
ImportError: cannot import name 'errors' from 'setuptools' (/opt/render/project/src/.venv/lib/python3.7/site-packages/setuptools/init.py)

Expected behavior

Install grpcio

How to Reproduce

  1. Make a flask application with grpcio library in the requirements.txt
  2. Deploy it on render
  3. Wait for it to get to grpcio
  4. Look at the error

Output

Collecting google-pasta==0.2.0 (from -r requirements.txt (line 30))
  Downloading https://files.pythonhosted.org/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57kB)
Collecting grpcio==1.60.0 (from -r requirements.txt (line 31))
  Downloading https://files.pythonhosted.org/packages/61/38/c615b5c2be690fb31871f294cc08a96e598b085b8d07c5967a5018e0b90c/grpcio-1.60.0.tar.gz (24.8MB)
    ERROR: Command errored out with exit status 1:
     command: /opt/render/project/src/.venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dgirmar6/grpcio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dgirmar6/grpcio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-dgirmar6/grpcio/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-dgirmar6/grpcio/setup.py", line 93, in <module>
        import commands
      File "/tmp/pip-install-dgirmar6/grpcio/src/python/grpcio/commands.py", line 31, in <module>
        import support
      File "/tmp/pip-install-dgirmar6/grpcio/src/python/grpcio/support.py", line 21, in <module>
        from setuptools import errors
    ImportError: cannot import name 'errors' from 'setuptools' (/opt/render/project/src/.venv/lib/python3.7/site-packages/setuptools/__init__.py)
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 23.3.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
==> Build failed 😞
@StarSupreme StarSupreme added bug Needs Triage Issues that need to be evaluated for severity and status. labels Feb 1, 2024
@abravalheri
Copy link
Contributor

Hi @StarSupreme, please note that unfortunately the setuptools project does not have the bandwidth to support a LTS version and that all bugfixes are added directly to the latest version without backport. This means that we can only support bugs that are present in the latest version of setuptools.

So the first step here is to test the latest version of setuptools.

I understand that you have limitations in terms of Python version. However, note that for debugging you don't need to install ALL the libraries you are using in your project. In fact we strongly recommend you create a minimal reproducer. This means that you should try to avoid requirements.txt and only actually install the libraries related to the problem. This way you should be able to install the latest version of setuptools.

Also please note that simply installing setuptools via pip does not mean that the version you installed will be used when installing other packages. To ensure 100% that you need:

  1. Create a new virtual environment
  2. Install the latest version of pip
  3. Install the latest version of setuptools and wheel
  4. Install all the correct versions of the build dependencies for the other packages you are trying to install (this and this may give you some hints of what they are in the case of grpcio, but you might have to look through the docs).
  5. Then you can run pip install <...> --no-build-isolation

Also ideally it would be nice if you can run these steps in a reproducible environment, e.g. a container. The fact that you mentioned that This only happens in Render is a big red flag, maybe there is something wrong in the render environment?

If you manage to create a minimal reproducer for the latest version of setuptools, please let us know the exact steps and logs. Otherwise, that means that the error is likely to have already been solved in the latest version of setuptools.

@abravalheri abravalheri added Needs Repro Issues that need a reproducible example. Needs Simplified Reproducer A simplified (ideally minimal) reproducer needs to be provided so that investigation may proceed Needs Latest Version Test A test using the latest version of setuptools is needed before further investigation and removed bug Needs Triage Issues that need to be evaluated for severity and status. Needs Repro Issues that need a reproducible example. labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Latest Version Test A test using the latest version of setuptools is needed before further investigation Needs Simplified Reproducer A simplified (ideally minimal) reproducer needs to be provided so that investigation may proceed
Projects
None yet
Development

No branches or pull requests

3 participants
@abravalheri @StarSupreme and others