I install py3-pandas as following,
FROM alpine:latest
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --update \
python3 \
python3-dev \
py3-numpy py3-pandas py3-scipy py3-numpy-dev
Then I try to import pandas, it's not avaialble
bash-5.0# python3
Python 3.7.5 (default, Oct 17 2019, 12:25:15)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>> import sys
>>> sys.path
['', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/lib/python3.7/site-packages', '/retention']
>>>
So it turns out pandas are installed in the different python directory
bash-5.0# apk info -L py3-pandas
....
usr/lib/python3.8/site-packages/pandas/__pycache__/__init__.cpython-38.pyc
bash-5.0# ls /usr/bin/python*
/usr/bin/python /usr/bin/python2.7 /usr/bin/python3-config /usr/bin/python3.7-config /usr/bin/python3.7m-config
/usr/bin/python2 /usr/bin/python3 /usr/bin/python3.7 /usr/bin/python3.7m
How do I make py3-pandas
to use the python version which is already installed in the system?
There are several ways of going about installing Pandas on a computer. The methods listed in this post are fairly simple, and it shouldn't take you longer than five minutes to get Pandas set up on your machine.
pandas can be installed via pip from PyPI.
You're mixing your versions - your Dockerfile is using latest
but you're including "edge" repositories.
To use Python 3.7 (no testing repo), you could use the following:
FROM alpine:latest
RUN echo "http://dl-8.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
but you risk changing versions in the future. Best to use:
FROM alpine:3.10
RUN echo "http://dl-8.alpinelinux.org/alpine/v3.10/community" >> /etc/apk/repositories
If you really want Python 3.8 and "testing" repo, you'll have to use latest
(again at the risk of changing versions):
FROM alpine:edge
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With