With this minimal Dockerfile
FROM public.ecr.aws/lambda/python:3.8
RUN pipenv lock -r > requirements.txt
The pipenv command fails with the error message:
Usage: pipenv lock [OPTIONS]
Try 'pipenv lock -h' for help.
Error: No such option: -r
And, so, the docker build fails with
The command '/bin/sh -c pipenv lock -r > requirements.txt' returned a non-zero code: 2
My pipenv is in version 2023.2.4.
pipenv lock -h doesn't show the option -r exists and I can't find anything online for this. Is the option deprecated? Is it changed?
You are correct, this command does not work anymore
pipenv lock -r > requirements.txt
The recommended replacement is
pipenv requirements > requirements.txt
As pointed in the issue 5253 from there issue tracker.
Related
This question already has answers here:
WARNING: Running pip as the 'root' user
(4 answers)
Closed 10 months ago.
I have this Dockerfile:
FROM python:3.8-slim
WORKDIR /app
COPY . .
RUN apt-get update
RUN apt-get install -y python3 python3-pip python3-venv
RUN pip freeze > requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
CMD ["python3", "main.py"]
Everything works file until this line:
RUN pip install --no-cache-dir -r requirements.txt
Using docker run --rm -it name bash and pip install -r requirements.txt then I found this error:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting
behaviour with the system package manager. It is recommended to use a virtual environment
instead: https://pip.pypa.io/warnings/venv
Here, I found solution (which didn't work for me), that it's possible to resolve just by creating new user, but it doesn't seem to be optimal solution. How can I fix this?
In this case the problem was in version of images. Using this Dockerfile I was able to fix this:
FROM python:3.9.3
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python3", "main.py"]
PS. I don't really know if it was about it, but this images has the same python version, that I have on my computer. I could have impact on dependencies.
I am building this image from this docker file
FROM python:3.8.0
WORKDIR /app
# Install system libraries
RUN apt-get update && \
apt-get install -y git && \
apt-get install -y gcc
# Install project dependencies
COPY ./requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt --use-deprecated=legacy-resolver
# Don't use terminal buffering, print all to stdout / err right away
ENV PYTHONUNBUFFERED 1
and this is my requirements.txt file
aiohttp==3.6.2
rasa==2.4.1
rasa-sdk==2.4.1
# Rasa requirements
python-dateutil~=2.8
SQLAlchemy==1.3.23
gast==0.3.3
the command to build the image
docker build -f base_Dockerfile -t rasa_base:latest
but this is showing this error
#9 529.6 ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
#9 529.6 tensorflow<2.4,>=2.3 from https://files.pythonhosted.org/packages/10/f9/283e82c10958fc24eb120fea6c40f1d8a66507a85818de420138bbbf88bf/tensorflow-2.3.2-cp38-cp38-manylinux2010_x86_64.whl#sha256=c85d29c7b5c000b196200a25e18a5905cc04f75c989e508f8fd110f3b2c4b4fe (from rasa==2.4.1->-r requirements.txt (line 2)):
#9 529.6 Expected sha256 c85d29c7b5c000b196200a25e18a5905cc04f75c989e508f8fd110f3b2c4b4fe
#9 529.6 Got c29a17cebd72dd06fecffd646fa0990c9b7f7b5781d8746b70d821109125f9c9
#9 529.6
------
executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt --use-deprecated=legacy-resolver]: exit code: 1
I have deleted all the images, and even I am using --no-cache-dir while installing the deps.
The issue was with cache and unused images. This command helped me
docker system prune -a
Remove all dangling images. If -a is specified, will also remove all images not referenced by any container
I am trying to install a package that is not on PyPi. i.e from github. Adding the repo as git+url to the requirements file gives
ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git clone -q https://github.com/Rapptz/discord-ext-menus /tmp/pip-req-build-147rct22
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
Installing the packages is done with
RUN python3 -m pip install -r requirements.txt
as specified in the docs
I also tried the solutions from this, but the answers mess up my other packages.
The dockerfile is almost directly from the docs
FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt
COPY . .
CMD [ "python3", "main.py"]
requirements.txt
asyncpg==0.21.0
git+https://github.com/Rapptz/discord-ext-menus
discord.py==1.7.0
pre-commit==2.10.1
pyclean==2.0.0
pylint==2.6.0
python-dotenv==0.15.0
As the error tells us, we have to simply install git, so that pip can clone the repo and run the setup file.
We can install git with
RUN apt-get update && apt-get install -y git
We also have to build from a python image, the above answer works with python:3.8-slim-buster
What I tried:
placing 'pip install --user -r requirements.txt' in the second run command
placing 'pip install pytest' in the second run command along with 'pip install pytest-html'
both followed by,
pytest --html=pytest_report.html
I am new to CircleCI and using pytest as well
Here is the steps portion of the config.yml file
version: 2.1
jobs:
run_tests:
docker:
- image: circleci/python:3.9.1
steps:
- checkout
- run:
name: Install Python Dependencies
command:
echo 'export PATH=~$PATH:~/.local/bin' >> $BASH_ENV && source $BASH_ENV
pip install --user -r requirements.txt
- run:
name: Run Unit Tests
command:
pip install --user -r requirements.txt
pytest --html=pytest_report.html
- store_test_results:
path: test-reports
- store_artifacts:
path: test-reports
workflows:
build_test:
jobs:
- run_tests
--html is not one of the builtin options for pytest -- it likely comes from a plugin
I believe you're looking for pytest-html -- make sure that's listed in your requirements
it's also possible / likely that the pip install --user is installing another copy of pytest into the image which'll only be available at ~/.local/bin/pytest instead of whatever pytest comes with the circle ci image
disclaimer, I'm one of the pytest core devs
This is my requirements.txt doc
1 BeautifulSoup==3.2.0
2 -e git://github.com/django/django#f92c9bd5eb272d537051c114bf57ed3aec132b48#egg=Django-dev
I am getting an error when I run sudo pip install --upgrade -r requirements.txt
Obtaining Django from git+git://github.com/django/django#f92c9bd5eb272d537051c114bf57ed3aec132b48#egg=Django-dev (from -r requirements.txt (line 2))
Command /usr/local/bin/git config remote.origin.url failed with error code 1
Storing complete log in /Users/nai/.pip/pip.log`
I am running Git 1.7.8.3.
I created my virtualenv using mkvirtualenv --no-site-packages <name>
I am using a Mac OS X Lion.
I have read this https://github.com/pypa/pip/issues/58#issuecomment-1337640 but I'm not sure exactly of the steps I should be taking to rectify the problem?
There's a workaround in the thread you linked: change lines 114-118 of pip/vcs/git.py to read:
def get_url(self, location):
url = call_subprocess(
[self.cmd, 'config', 'remote.origin.url'],
show_stdout=False, cwd=location, raise_on_returncode=False)
return (url or '').strip()