Installing ruamel.yaml.clib with docker - python

I have a small project in django rest framework and I want to dockerize it. In my requirements.txt file there is a package called ruamel.yaml.clib==0.2.6. While downloading all other requirements is successfull, there is a problem when it tries to download this package.
#11 208.5 Collecting ruamel.yaml.clib==0.2.6
#11 208.7 Downloading ruamel.yaml.clib-0.2.6.tar.gz (180 kB)
#11 217.8 ERROR: Command errored out with exit status 1:
#11 217.8 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-n2gr5j35
#11 217.8 cwd: /tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/
#11 217.8 Complete output (3 lines):
#11 217.8 sys.argv ['/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py', 'egg_info', '--egg-base', '/tmp/pip-pip-egg-info-n2gr5j35']
#11 217.8 test compiling /tmp/tmp_ruamel_erx3efla/test_ruamel_yaml.c -> test_ruamel_yaml compile error: /tmp/tmp_ruamel_erx3efla/test_ruamel_yaml.c
#11 217.8 Exception: command 'gcc' failed: No such file or directory
#11 217.8 ----------------------------------------
#11 217.8 WARNING: Discarding https://files.pythonhosted.org/packages/8b/25/08e5ad2431a028d0723ca5540b3af6a32f58f25e83c6dda4d0fcef7288a3/ruamel.yaml.clib-0.2.6.tar.gz#sha256=4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd (from https://pypi.org/simple/ruamel-yaml-clib/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#11 217.8 ERROR: Could not find a version that satisfies the requirement ruamel.yaml.clib==0.2.6 (from versions: 0.1.0, 0.1.2, 0.2.0, 0.2.2, 0.2.3, 0.2.4, 0.2.6)
#11 217.8 ERROR: No matching distribution found for ruamel.yaml.clib==0.2.6
However, there is no problem when I download this package without docker. Any suggestions?
Here is Dockerfile:
FROM python:3-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install -U pip setuptools wheel ruamel.yaml ruamel.yaml.clib==0.2.6
COPY ./requirements.txt .
RUN pip install --default-timeout=100 -r requirements.txt
# copy project
COPY . .
Here is compose file
version: '3.8'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/usr/src/app
ports:
- 8000:8000
env_file:
- ./.env.dev
EDIT
As mentioned in comments by #Anthon, the problem was related to alpine. I used python:3.9-slim-buster instead in Dockerfile and problem solved!

I see that OP has moved on from Alpine to solve this issue, but for whatever reason you need/want/wish to stay on Alpine, you can install gcc, musl-dev, and python3-dev:
⋮
RUN apk add --no-cache gcc musl-dev python3-dev
⋮
RUN pip install ruamel.yaml.clib …

I think the problem is with the way your Dockerfile tries to install ruamel.yaml.clib. It should be installed using pip (just as documented for the ruamel.yaml).
I suggest you take it out of the requirements.txt and explicitly do a
pip install -U pip setuptools wheel ruamel.yaml.clib==0.2.6
in your Dockerfile instead. This should just get you the pre-compiled wheel instead of trying to compile ruamel.yaml.clib from source, which will not work if you don't have a C compiler installed (this is actually what docker complains about)
I have ruamel.yaml.clib running succesfully in multiple Docker containers (but I never use a requirements.txt)

Related

Problems installing fbprophet on ubuntu 18.04 not working

I have a docker image based on ubuntu 18.04, where I am trying to install fbprophet. I installed python3.7 dev, libpcap-dev libpq-dev and build essentials with this command
RUN apt-get install -y python3-pip libsm6 libxext6 python3.7-dev build-essential libncursesw5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev libbz2-dev libffi-dev zlib1g-dev libpcap-dev libpq-dev
I then installed following packages in the following way
RUN pip3 install numpy==1.19.5
RUN pip3 install pandas==1.1.5
RUN pip3 install Pillow==8.2.0
RUN pip3 install PyMeeus==0.5.11
RUN pip3 install pyparsing==2.4.7
RUN pip3 install cmdstanpy==0.9.5 Cython==0.29.3 ephem==4.0.0.2 hijri_converter==2.1.3 convertdate==2.3.2 korean_lunar_calendar==0.2.1 lunarcalendar==0.0.9 holidays==0.11.1 cython tqdm==4.61.1 pystan==2.17.1
Finally I tried to install fbprohet 0.7.1, but then I get the following error:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
I have tried researching this issue, and the common solution seemed to be to install python3.x-dev, build essentials and libpcap-dev libpq-dev, which I have already.
I am researching this issue for quite some time now, but this error message persists, is there any solution to it?
Edit:
This is the full error message:
command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yc4ch36e/fbprophet_6cbb80365f414249ac2d886e0e6a654d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yc4ch36e/fbprophet_6cbb80365f414249ac2d886e0e6a654d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-hv6ghna1
cwd: /tmp/pip-install-yc4ch36e/fbprophet_6cbb80365f414249ac2d886e0e6a654d/
Complete output (19 lines):
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
DIAGNOSTIC(S) FROM PARSER:
Warning: left-hand side variable (name=cp_idx) occurs on right-hand side of assignment, causing inefficient deep copy to avoid aliasing.
Warning: left-hand side variable (name=m_pr) occurs on right-hand side of assignment, causing inefficient deep copy to avoid aliasing.
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec NOW.
/usr/local/lib/python3.6/dist-packages/Cython/Compiler/Main.py:367: FutureWarning:
Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/tmpwga4ct8b/stanfit4anon_model_dfdaf2b8ece8a02eb11f050ec701c0ec_6094426740594523141.pyx
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
----------------------------------------
ERROR: Failed building wheel for fbprophet
```

Docker : Alpine : Django - Error installing python mysqlclient library [duplicate]

This question already has answers here:
Docker Alpine: Error loading MySQLdb module
(2 answers)
Closed 1 year ago.
I am building an Alpine based image of a Django application to connect with a MySQL db. For connecting with the database, I am using mysqlclient. For building the image, I am using docker-compose. When I do docker-compose build I get the respective error:
#15 7.366 Downloading mysqlclient-1.3.0.tar.gz (76 kB)
#15 7.403 Preparing metadata (setup.py): started
#15 7.545 Preparing metadata (setup.py): finished with status 'error'
#15 7.545 ERROR: Command errored out with exit status 1:
#15 7.545 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-wh30qihi
#15 7.545 cwd: /tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/
#15 7.545 Complete output (10 lines):
#15 7.545 /bin/sh: mysql_config: not found
#15 7.545 Traceback (most recent call last):
#15 7.545 File "<string>", line 1, in <module>
#15 7.545 File "/tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/setup.py", line 17, in <module>
#15 7.545 metadata, options = get_config()
#15 7.545 File "/tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/setup_posix.py", line 47, in get_config
#15 7.545 libs = mysql_config("libs_r")
#15 7.545 File "/tmp/pip-install-3fyj3dl9/mysqlclient_4a600f29b1334b47a39251a3f24d8315/setup_posix.py", line 29, in mysql_config
#15 7.545 raise EnvironmentError("%s not found" % (mysql_config.path,))
#15 7.545 OSError: mysql_config not found
#15 7.545 ----------------------------------------
#15 7.545 WARNING: Discarding https://files.pythonhosted.org/packages/6a/91/bdfe808fb5dc99a5f65833b370818161b77ef6d1e19b488e4c146ab615aa/mysqlclient-1.3.0.tar.gz#sha256=06eb5664e3738b283ea2262ee60ed83192e898f019cc7ff251f4d05a564ab3b7 (from https://pypi.org/simple/mysqlclient/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#15 7.545 ERROR: Could not find a version that satisfies the requirement mysqlclient (from versions: 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.3.9, 1.3.10, 1.3.11rc1, 1.3.11, 1.3.12, 1.3.13, 1.3.14, 1.4.0rc1, 1.4.0rc2, 1.4.0rc3, 1.4.0, 1.4.1, 1.4.2, 1.4.2.post1, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0rc1)
#15 7.546 ERROR: No matching distribution found for mysqlclient
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c python -m pip install mysqlclient]: exit code: 1
This is my Django Dockerfile
# Base image for newly image. Alpine version is lightweigther.
FROM python:3.9-alpine
ENV PYTHONUNBUFFERED 1
# Set app directory
WORKDIR /app
COPY . /app/
# install python dependencies
RUN python -m pip install --upgrade pip
# dependencies
RUN python -m pip install Django djangorestframework django-extensions
RUN python -m pip install mysqlclient
RUN python -m pip install python-dotenv
And this is my docker-compose.yaml
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
version: '3.8'
# Different Components of the Application
services:
# Database Service (Mysql)
app-db:
container_name: theater-platform-db
image: mysql:5.7
ports:
- '2003:3306'
restart: always
environment:
MYSQL_DATABASE: theater_platform
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_USER_PW}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PW}
volumes:
- ./volumes/db-data:/var/lib/mysql
networks:
- backend
healthcheck:
test: 'mysqladmin ping -h theater-platform-db -P 3306 -u ${DB_USER} --password="${DB_USER_PW}"'
timeout: 10s
retries: 3
app-backend:
container_name: theater-platform-django-api-server
build:
context: backend
dockerfile: Dockerfile
ports:
- '2004:8000'
command: >
sh -c 'python manage.py makemigrations &&
python manage.py migrate &&
python manage.py runserver 8000'
restart: on-failure
environment:
DEBUG: '1'
DB_HOST: theater-platform-db
DB_PORT: 3306
DB_NAME: theater_platform
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_USER_PW}
volumes:
- ./volumes/app-data:/app/appdata
networks:
- backend
- frontend
depends_on:
app-db:
condition: service_healthy
app-frontend:
container_name: theater-platform-web-ui
build:
context: frontend
dockerfile: Dockerfile
ports:
- '2005:8080'
networks:
- frontend
volumes:
db-data:
app-data:
networks:
backend:
frontend:
Does anyone know how to fix it? I have tried to see proper documentation but with no success.
this link is the awsner
you forgot to install one library to compile mysqlclient

How to install psycopg2 on Python 3.9 on Windows?

I have been trying to install psycopg2 (pip install psycopg2), but I keep getting this error.
I have also tried with: pip install psycopg2-binary but I'm getting the same error.
Here is the error message:
ERROR: Command errored out with exit status 1:
command: 'c:\users\viktor\pycharmprojects\wemport\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycop
g2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycopg2\\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\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl'
cwd: C:\Users\Viktor\AppData\Local\Temp\pip-install-015ceiei\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info
writing C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How to fix that?
The following will install prebuilt binaries for windows. It's worked for me on 3.9. You can uninstall pipwin after install psycopg2.
pip install pipwin
pipwin install psycopg2
Optional after psycopg2 installed:
pip uninstall pipwin
if u use linux
You need to make sure that you install wheel model
and Try that
sudo ./venv/bin/python -m pip install wheel
after that install psycopg2 and psycopg2-binary
sudo ./venv/bin/python -m pip install psycopg2
sudo ./venv/bin/python -m pip install psycopg-binary

How to import pygame in gitpod?

This is a simple SudokuSolver App.
Project on GitHub
It's working perfectly. But when I try to run it in gitpod it's unable to import pygame.
Error:
gitpod /workspace/SudokuVizualizationBacktracking $ /home/gitpod/.pyenv/versions/3.8.2/bin/python /workspace/SudokuVizualizationBacktracking/GUI.py
Traceback (most recent call last):
File "/workspace/SudokuVizualizationBacktracking/GUI.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
Can you please help me out? Thanks You.
In your .gitpod.yml you have configured the following init task:
$ pip3 install -r requirements.txt
Start your workspace by opening https://gitpod.io/#https://github.com/Deepak-dash007/SudokuVizualizationBacktracking and run this command in the terminal. You'll get the following output:
$ pip3 install -r requirements.txt
Collecting pygame
Downloading pygame-1.9.6.tar.gz (3.2 MB)
|████████████████████████████████| 3.2 MB 6.8 MB/s
ERROR: Command errored out with exit status 1:
command: /home/gitpod/.pyenv/versions/3.8.2/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fgexue3e/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fgexue3e/pygame/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-9lyba20o
cwd: /tmp/pip-install-fgexue3e/pygame/
Complete output (12 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
Hunting dependencies...
WARNING: "sdl-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Here you can see that sdl-config is missing. Google found this Stack Overflow answer that lists dependencies needed for pygame: https://stackoverflow.com/a/60990677/1364435
Change your image config in your .gitpod.yml to:
image:
file: .gitpod.Dockerfile
and added a new file .gitpod.Dockerfile that installs the dependencies linked in the other Stack Overflow post:
FROM gitpod/workspace-full-vnc
RUN sudo apt-get update && sudo apt-get install -y \
python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev
Push everything and create a new Gitpod workspace. That's it.
You'll find a running repo here https://github.com/corneliusludmann/SudokuVizualizationBacktracking
I also created a Pull Request for you: https://github.com/Deepak-dash007/SudokuVizualizationBacktracking/pull/1

httptools build fails while setting up rasa nlu

Cloned the repo : https://github.com/RasaHQ/rasa_nlu.git
$ pip install -r requirements.txt
Building wheel for httptools (setup.py) ... error ERROR: Complete
output from command /Users/mohit/anaconda3/envs/condapy36/bin/python
-u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/9t/0qgpwgy906z_sww71dnkgkr80000gn/T/pip-install-7hmlhuo6/httptools/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))'
bdist_wheel -d
/private/var/folders/9t/0qgpwgy906z_sww71dnkgkr80000gn/T/pip-wheel-u02mzs5m
--python-tag cp36: ERROR: running bdist_wheel
error: command 'gcc' failed with exit status 1
---------------------------------------- ERROR: Failed building wheel for httptools Running setup.py clean for httptools Building
wheel for ujson (setup.py) ... error
$ pip install -e .
Obtaining file:///Users/mohit/work/research/NLP/Rasa/rasa_nlu ERROR:
Error installing
'file:///Users/mohit/work/research/NLP/Rasa/rasa_nlu': editable mode
is not supported for pyproject.toml-style projects. pip is processing
this project as pyproject.toml-style because it has a pyproject.toml
file. Since the project has a setup.py and the pyproject.toml has no
"build-backend" key for the "build_system" value, you may pass
--no-use-pep517 to opt out of pyproject.toml-style processing. See PEP 517 for details on pyproject.toml-style projects.
OS : Mac OS High Sierra
Python 3.6.8 :: Anaconda custom (64-bit)
pip 19.1
That's was actually in issue in pip (https://github.com/pypa/pip/issues/6375).
Please install using pip install --no-use-pep517 -e . or upgrade pip to the latest version.
check for visual studio, redists, vc++ and allied syncing up

Categories

Resources