Alpine error during installing python shapely - python

I need to install Shapely into Python+Alpine based docker container. What I already have inside the container:
make, gcc, geos-dev, musl-dev
What I got with this command:
pip install shapely
Collecting shapely
Downloading https://files.pythonhosted.org/packages/a2/fb/7a7af9ef7a35d16fa23b127abee272cfc483ca89029b73e92e93cdf36e6b/Shapely-1.6.4.post2.tar.gz (225kB)
|████████████████████████████████| 235kB 641kB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vj51jvsy/shapely/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vj51jvsy/shapely/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 /tmp/pip-install-vj51jvsy/shapely/pip-egg-info
cwd: /tmp/pip-install-vj51jvsy/shapely/
Complete output (11 lines):
Failed `CDLL(libgeos_c.so.1)`
Failed `CDLL(libgeos_c.so)`
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-vj51jvsy/shapely/setup.py", line 80, in <module>
from shapely._buildcfg import geos_version_string, geos_version, \
File "/tmp/pip-install-vj51jvsy/shapely/shapely/_buildcfg.py", line 167, in <module>
fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
File "/tmp/pip-install-vj51jvsy/shapely/shapely/_buildcfg.py", line 161, in load_dll
libname, fallbacks or []))
OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I googled around much time but can't find any solving.
Dockerfile
FROM python:3.7-alpine
RUN ["mkdir", "/home/test"]
WORKDIR /home/test
RUN echo "http://mirror.leaseweb.com/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN ["apk", "add", "make", "gcc", "geos-dev", "musl-dev"]
RUN ["pip3", "install", "virtualenv", "--no-warn-script-location", "--disable-pip-version-check"]
RUN ["virtualenv", ".env", "--python=python3"]
RUN ["pip3", "install", "shapely"]
CMD ["/bin/sh"]
Version of Python inside the container
/home/test # /usr/local/bin/python
Python 3.7.5 (default, Oct 21 2019, 20:13:45)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
GEOS version
/home/test # geos-config --version
3.7.2
UPDATED
Now you must put this repo beneath others:
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community

This will work:
FROM python:3.7-alpine
RUN ["mkdir", "/home/test"]
WORKDIR /home/test
RUN echo "http://mirror.leaseweb.com/alpine/edge/community" >> /etc/apk/repositories
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk add --virtual .build-deps \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
gcc libc-dev geos-dev geos && \
runDeps="$(scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| xargs -r apk info --installed \
| sort -u)" && \
apk add --virtual .rundeps $runDeps
RUN ["pip", "install", "shapely"]
CMD ["/bin/sh"]
see this
UPDATE: As per comments, geos-dev has moved to the community repo.

I hit this problem with my build as well. My workaround was to switch from Alpine to Debian (not ideal, but it allowed me to use an older version of geos), since it appears the latest version of geos is incompatible with shapely.

Related

Error: Command errored out with exit status 1: (really long command)

$ cd surface_dynamics
$ pip3 install .
Processing /Users/jacobelection/surface_dynamics
ERROR: Command errored out with exit status 1:
command: /usr/local/Caskroom/miniconda/base/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-req-build-ubkp2yci/setup.py'"'"'; __file__='"'"'/private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-req-build-ubkp2yci/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 /private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-pip-egg-info-jhapggrl
cwd: /private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-req-build-ubkp2yci/
Complete output (15 lines):
Traceback (most recent call last):
File "/private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-req-build-ubkp2yci/setup.py", line 9, in <module>
import sage.all
ModuleNotFoundError: No module named 'sage'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/m8/lmzlkfq11wj3rn17q7xm7g2m0000gn/T/pip-req-build-ubkp2yci/setup.py", line 11, in <module>
raise ValueError("this package currently installs only inside SageMath (http://www.sagemath.org)\n"
ValueError: this package currently installs only inside SageMath (http://www.sagemath.org)
If you are using Ubuntu with Sage installed from the official apt repository, run
first in a console "$ source /usr/share/sagemath/bin/sage-env"
----------------------------------------
WARNING: Discarding file:///Users/jacobelection/surface_dynamics. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How could I fixed these problem? My python version is 3.8.3. macOS Big Sur 11.1
The command needs to be run with the pip that
corresponds to SageMath's Python, which would
depend on the way SageMath was installed:
built from source?
from binaries from the SageMath download page?
from Marc Culler's SageMath app?
via Homebrew cask?
via Conda?
One way to go is to install the SageMath macOS app from
https://github.com/3-manifolds/Sage_macOS/releases
and run the Recommended.pkg installer.
Then instead of
pip3 install .
run
sage --pip install .
Or if you installed SageMath via Conda, make sure to
first activate the corresponding Conda environment:
conda activate sage
pip install .
In case of doubt, check what pip is going to be called
with commands such as:
which pip
ls -halF $(which pip)
which pip3
ls -halF $(which pip3)

PyQt-Fit installation failed

Installation failed on Windows 10 machine for Python 3.8.3
pip install PyQt-Fit
ERROR: Command errored out with exit status 1:
command: 'c:\users\mkz\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setup.py'"'"'; file='"'"'C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\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 'C:\Users\mkz\AppData\Local\Temp\pip-pip-egg-info-6yfk5kue'
cwd: C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute
Complete output (15 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setuptools_init_.py", line 2, in
from setuptools.extension import Extension, Library
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setuptools\extension.py", line 5, in
from setuptools.dist import get_unpatched
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setuptools\dist.py", line 7, in
from setuptools.command.install import install
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setuptools\command_init.py", line 8, in
from setuptools.command import install_scripts
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\setuptools\command\install_scripts.py", line 3, in
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "C:\Users\mkz\AppData\Local\Temp\pip-install-rn6exgn0\distribute\pkg_resources.py", line 1518, in
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
After spending a few hours, I realized that maybe PyQt-Fit only works with python 2.7 then I created a conda environment with python 2.7 and created a kernel
//This is for conda to support switching kernels
conda install nb_conda
conda create -n py27 python=2.7
conda activate py27
//install PyQt-Fit
pip install -I path.py==7.7.1
pip install git+https://github.com/Multiplicom/pyqt-fit.git
// This is needed for Jupyter Notebook connecting with new kernel
pip install pypiwin32
//Make sure you are at the same directory as the py27 env, for example, C:\Anaconda3\envs\py27
//Create a new kernel
conda install notebook ipykernel
ipython kernelspec install-self
//now run jupyter notebook
A few useful links that helped me to get things fixed.
https://docs.continuum.io/anaconda/user-guide/tasks/use-jupyter-notebook-extensions/
https://github.com/ipython/ipykernel/issues/52
In which conda environment is Jupyter executing?
PyQt_Fit: cannot import name path

No such file or directory error when installing github package in anaconda

I am trying to install this module from github.
https://github.com/ChristianSchneeweiss/Chat-txt-to-csv
First, I am following the steps listed here.
https://medium.com/i-want-to-be-the-very-best/installing-packages-from-github-with-conda-commands-ebf10de396f4
so I used this line in Anaconda Powershell Prompt
pip install git+git://github.com/ChristianSchneeweiss/Chat-txt-to-csv.git
it didn't work. and then I used this code, based on the suggestions here.
Use package from Github in Conda Virtual Environment
pip install C:\Users\Lulz\Documents\mamanitip\chat_wa\Chat-txt-to-csv-master.zip
it didn't work either. both codes resulted in this error.
command: 'C:\ProgramData\Anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Lulz\\AppData\\Local\\Temp\\pip-req-build-2cr6dd41\\setup.py'"'"'; __file__='"'"'C:\\Users\\Lulz\\AppData\\Local\\Temp\\pip-req-build-2cr6dd41\\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 'C:\Users\Lulz\AppData\Local\Temp\pip-pip-egg-info-3o0zsjkm'
cwd: C:\Users\Lulz\AppData\Local\Temp\pip-req-build-2cr6dd41\
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Lulz\\AppData\\Local\\Temp\\pip-req-build-2cr6dd41\\setup.py'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
i've tried creating new Microsoft accounts, and installing in a new environment, but it still didn't work. it always resulted in the same error, just different users (as I change Microsoft accounts). what did I do wrong? thank you so much for your help.
The package at https://github.com/ChristianSchneeweiss/Chat-txt-to-csv cannot be installed with pip because it does not have the file setup.py. What you can do instead is to download the project onto your computer, install the project's dependencies, and then use the project from its directory. If you run python from within that project's directory, it will find the package.
git clone https://github.com/ChristianSchneeweiss/Chat-txt-to-csv
cd Chat-txt-to-csv
python -m pip install --no-cache-dir -r requirements.txt
python convert.py chat.txt

Python MariaDB pip install failed, missing mariadb_config

I am using Linux Ubuntu 18.04 and python 3. I am trying to build a connection between a maria-db and my python scripts. Therefore I have to install the mariadb package.
I have already installed:
sudo apt install mariadb-server
But when i try:
pip install mariadb
I get following error:
Collecting mariadb
Using cached mariadb-1.0.0.tar.gz (78 kB)
ERROR: Command errored out with exit status 1:
command: /home/niklas/Desktop/Stuff/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pycharm-packaging/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pycharm-packaging/mariadb/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 /tmp/pip-pip-egg-info-wfnscxnz
cwd: /tmp/pycharm-packaging/mariadb/
Complete output (12 lines):
/bin/sh: 1: mariadb_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pycharm-packaging/mariadb/setup.py", line 26, in <module>
cfg = get_config(options)
File "/tmp/pycharm-packaging/mariadb/mariadb_posix.py", line 49, in get_config
cc_version = mariadb_config(config_prg, "cc_version")
File "/tmp/pycharm-packaging/mariadb/mariadb_posix.py", line 27, in mariadb_config
"mariadb_config not found.\nPlease make sure, that MariaDB Connector/C is installed on your system, edit the configuration file 'site.cfg' and set the 'mariadb_config'\noption, which should point to the mariadb_config utility.")
OSError: mariadb_config not found.
Please make sure, that MariaDB Connector/C is installed on your system, edit the configuration file 'site.cfg' and set the 'mariadb_config'
option, which should point to the mariadb_config utility.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Can anybody help me ?
Edit:
I have now been able to connect to the server but not with te mariadb package. (https://linuxhint.com/connect_mariadb_pymysql/)
Install MariaDB Connector/C, which is a dependency.
sudo apt-get install libmariadb3 libmariadb-dev
Use PIP to install MariaDB Connector/Python.
pip3 install mariadb
To install mariadb python module, you have to install a recent version of MariaDB Connector/C, minimum required version is 3.1.5, afaik Ubuntu 18.04 has 3.0.3.
An actual version of Connector/C for bionic is available on the MariaDB Connector/C Download Page.
If you want to install it in a special directory, make sure that the PATH and LD_LIBRARY_PATH point to bin and lib directories.
I also recommend to use a recent version of MariaDB Server, especially the very fast executemany() method will be much slower on MariaDB Server < 10.2.
It seems you need to install it first on your OS.
You can follow this guide to install it properly.

Locale.Error with building python based docker

I am new to docker and would appreciate if someone can help me get rid of this error while building the docker image. It is giving some kind of locale error. How can I get rid of this error ?
Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
Collecting setuptools
Downloading setuptools-20.3.1-py2.py3-none-any.whl (508kB)
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-8.1.1 setuptools-20.3.1 wheel-0.29.0
+ pip install --no-cache-dir --upgrade pip==8.0.2
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in
sys.exit(main())
File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib64/python2.7/locale.py", line 547, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
The command '/bin/sh -c set -ex && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION' returned a non-zero code: 1
This is my Dockerfile:
FROM mybase:1.0.7
RUN set -x \
&& yum install -y python-devel libffi-devel python-cffi \
&& yum clean all
ENV LANG C.UTF-8
ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF
ENV PYTHON_VERSION 2.7.11
ENV PYTHON_PIP_VERSION 8.0.2
RUN set -ex \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
&& curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION
RUN pip install --no-cache-dir virtualenv
CMD ["python2"]
The locale.setlocale docs say the locale should be valid. If an empty string is passed, the LANG variable is used to set the locale. This error is probably caused because your LANG is not a supported locale
In your docker script, you set LANG to C.UTF-8. It looks like C.UTF-8 is not a supported locale in glibc and I am guessing hence in Python (See this and this).
You can set your LANG to a supported type like en_US.UTF-8 (The default on my computer).
On Python-2.6, I get the following results
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
'en_US.utf8'
>>> locale.setlocale(locale.LC_ALL, "C.UTF-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/locale.py", line 513, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
'en_US.UTF-8'
>>> locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
'de_DE.UTF-8'
You can view the locales available on your computer by running
$ locale -a

Categories