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

pip install wants to compile package on Docker python:3.9-slim #105

Closed
gitpushdashf opened this issue Jun 5, 2021 · 9 comments
Closed

Comments

@gitpushdashf
Copy link

I'm not sure what's going on here.

 % docker run -ti python:3.9 /bin/bash
root@1214f7af75e1:/# python3 -m pip install backports.zoneinfo
Collecting backports.zoneinfo
  Downloading backports.zoneinfo-0.2.1.tar.gz (74 kB)
     |████████████████████████████████| 74 kB 2.2 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: backports.zoneinfo
  Building wheel for backports.zoneinfo (PEP 517) ... done
  Created wheel for backports.zoneinfo: filename=backports.zoneinfo-0.2.1-cp39-cp39-linux_x86_64.whl size=83141 sha256=3965
fcaeae0b42b3bd8c07333402515e06d52e0d52ada70eb40f4530bfcf82b9
  Stored in directory: /root/.cache/pip/wheels/f6/da/c4/7ac0330c0d9763cbd549898f8815e8cbc01a5bd31a009be764
Successfully built backports.zoneinfo
Installing collected packages: backports.zoneinfo
Successfully installed backports.zoneinfo-0.2.1
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https
://pip.pypa.io/warnings/venv
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.
root@1214f7af75e1:/# exit
~ % docker run -ti python:3.9-slim /bin/bash
Unable to find image 'python:3.9-slim' locally
3.9-slim: Pulling from library/python
69692152171a: Already exists
59773387c0e7: Already exists
3fc84e535e87: Already exists
68ebeebdab6f: Already exists
3d3af2ef8baa: Pull complete
Digest: sha256:80b238ba357d98813bcc425f505dfa238f49cf5f895492fc2667af118dccaa44
Status: Downloaded newer image for python:3.9-slim
root@3dbd3fe63499:/# python3 -m pip install backports.zoneinfo
Collecting backports.zoneinfo
  Downloading backports.zoneinfo-0.2.1.tar.gz (74 kB)
     |████████████████████████████████| 74 kB 2.4 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: backports.zoneinfo
  Building wheel for backports.zoneinfo (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python3 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpmvgwhv8z
       cwd: /tmp/pip-install-locab8gm/backports-zoneinfo_46d7f44a7b1348bd808d538b0cb455b1
  Complete output (35 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/backports
  copying src/backports/__init__.py -> build/lib.linux-x86_64-3.9/backports
  creating build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/_common.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/__init__.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/_version.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  running egg_info
  writing src/backports.zoneinfo.egg-info/PKG-INFO
  writing dependency_links to src/backports.zoneinfo.egg-info/dependency_links.txt
  writing requirements to src/backports.zoneinfo.egg-info/requires.txt
  writing top-level names to src/backports.zoneinfo.egg-info/top_level.txt
  reading manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*.png' under directory 'docs'
  warning: no files found matching '*.svg' under directory 'docs'
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_output'
  adding license file 'LICENSE'
  adding license file 'licenses/LICENSE_APACHE'
  writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
  copying src/backports/zoneinfo/__init__.pyi -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  copying src/backports/zoneinfo/py.typed -> build/lib.linux-x86_64-3.9/backports/zoneinfo
  running build_ext
  building 'backports.zoneinfo._czoneinfo' extension
  creating build/temp.linux-x86_64-3.9
  creating build/temp.linux-x86_64-3.9/lib
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.9 -c lib/zoneinfo_module.c -o build/temp.linux-x86_64-3.9/lib/zoneinfo_module.o -std=c99
  error: command 'gcc' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for backports.zoneinfo
Failed to build backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo which use PEP 517 and cannot be installed directly
root@3dbd3fe63499:/# exit

Do you have any ideas on this? Thank you! python:3.8-slim works fine, which is puzzling.

@pauloxnet
Copy link

The problem is the lack of the py39 wheel on pypi so it try to compile it but gcc is missing.

@gitpushdashf you can add build-essential in your Dockerfile.

@pganssle can you add a python 3.9 wheel on pypi.org for zoneinfo 0.2.1?

@pganssle
Copy link
Owner

pganssle commented Jun 15, 2021

@pauloxnet zoneinfo is built in to Python 3.9, and at least at the moment I don't plan to backport new features from 3.11+ into backports.zoneinfo (unless there are some pretty killer features), so this package isn't really supported on Python 3.9+.

I think the right thing to do is to depend on backports.zoneinfo; python_version < '3.9', and in your code use:

try:
    from backports import zoneinfo
except ImportError:
    import zoneinfo

Or something similar.

I suppose it might also be feasible to just make backports.zoneinfo import zoneinfo from the standard library in Python 3.9+, and not install or compile anything, though I don't really want to paint myself into a corner with respect to backporting features from 3.11+.

@pauloxnet
Copy link

@pganssle thanks for your explanation, I confused version of python locally , now I fixed it.

@gitpushdashf
Copy link
Author

Thank you for explaining!

It's a 3rd party dependency, so I'll see if we can fix it there with the import.

@gitpushdashf
Copy link
Author

I'll go ahead and close this out. I think it makes sense to only require dependencies like this for the Python versions that need them.

grokpot pushed a commit to grokpot/wg_chatbot that referenced this issue Oct 8, 2021
not used within code (except obsolete code) it seems. so getting rid of
this dependency, as this module does no longer exist within Py3.9 and
built-in modules should be used.

details:
pganssle/zoneinfo#105
@Yalchin403
Copy link

Yalchin403 commented Nov 18, 2021

build-essential

ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN apt-get update \
    && apt-get -y install libpq-dev gcc
RUN pip install -r /requirements.txt
RUN mkdir /app
COPY . /app
WORKDIR /app```


this works fine for me, hope this is helpful

@melroy89
Copy link

melroy89 commented Dec 23, 2021

ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN apt-get update \
    && apt-get -y install libpq-dev gcc
RUN pip install -r /requirements.txt
RUN mkdir /app
COPY . /app
WORKDIR /app```


this works fine for me, hope this is helpful

Hint: If you first set your WORKDIR. You can use the COPY commands afterwards as follows: COPY . . (I know it's unrelated to the issue)

@yangislet
Copy link

it spent a lot of time, but it still not work! ERROR: Could not build wheels for backports.zoneinfo,

@safiullahkhan45
Copy link

This error arise because you have a difference of python versions in your local virtual environment and docker. Update your Dockerfile in the following way.
From this:
FROM python:3
to this:
FROM python:3.8

For me it works fine now.

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

7 participants