I am trying add the python-dev package to my requirements.txt file, but I must be using the wrong package name. I have tried:
python3.7-dev
python-dev
py-dev
If you want to install package at OS level you should seriously consider using a docker container to deploy/release your application.
Here is a snippet:
FROM python
RUN apt-get install python-dev
RUN pip install -r requirements.txt
...
I guess there's great explanation about how to install it:
How to install python developer package?
For it's installing you should use your operation system package manager, such as:
yum, dnf, apt-get, brew or kinda
Related
I'm trying to install python3-gnupg on my RHEL EC2 server.
I used the command
wget https://download.fedoraproject.org/../python-gnupg-0.4.6-1.fc32.src.rpm
sudo rpm -i file.rpm
Get the error
error: Failed dependencies:
python(abi) = 3.8 is needed by python3-gnupg-0.4.6-1.fc32.noarch
rpmlib(PayloadIsZstd) <= 5.4.18-1 is needed by python3-gnupg-0.4.6-1.fc32.noarch
How do I download & install all dependencies at once?
You may want to use dnf or yum (if dnf is not available for some reason) to install your package instead of the rpm command.
Why ?
Because it will actually download dependencies. The rpm command does not comes with a 'remote repository' like yum or dnf, thus its incapacity to download missing dependencies.
Command for dnf:
sudo dnf install https://download.fedoraproject.org/../python-gnupg-0.4.6-1.fc32.src.rpm
Command for yum:
sudo yum install https://download.fedoraproject.org/../python-gnupg-0.4.6-1.fc32.src.rpm
(you can replace the URL by the path to your RPM file and you'll want to replace the URL by the correct one)
You may still have a problem with python.
Indeed, it requires a fixed version of python (the 3.8 version) and dnf/yum may refuse to install one.
You have two ways to fix this.
The first way
Install the python3-gnupg package directly from the RHEL repo (if available, I'm not quite sure) to directly install the correct dependencies (and the version corresponding to your distro that received the RHEL tests blessing)
So you may try
sudo dnf install python3-gnupg
Or
sudo yum install python3-gnupg
The second way
Try to install the corresponding version of python. Either with dnf or yum.
sudo dnf install python3.8
Or
sudo yum install python3.8
What I would recommend
IMHO, the first solution is better because you'll actually get the official RHEL version of the python3-gnupg, which has been build for your distro AND tested accordingly. But it may not be available. I actually tested those commands on my Fedora 33, because it uses the same tools as RHEL, but its dnf/yum repositories are actually different.
I am dealing with a legacy Dockerfile. Here is a very simplified version of what I am dealing with:
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install \
python-pip \
python-numpy # ...and many other packages
RUN pip install -U pip
RUN pip install -r /tmp/requirements1.txt # includes e.g., numpy==1.13.0
RUN pip install -r /tmp/requirements2.txt
RUN pip install -r /tmp/requirements3.txt
First, several packages are installed using apt, and then several packages are installed using pip. pip version 10 has been released, and part of the release is this new restriction:
Removed support for uninstalling projects which have been installed using distutils. distutils installed projects do not include metadata indicating what files belong to that install and thus it is impossible to actually uninstall them rather than just remove the metadata saying they've been installed while leaving all of the actual files behind.
This leads to the following problem in my setup. For example, first apt installs python-numpy. Later pip tries to install a newer version of numpy from e.g., /tmp/requirements1.txt, and tries to uninstall the older version, but because of the new restriction, it cannot remove this version:
Installing collected packages: numpy
Found existing installation: numpy 1.8.2
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Now I know at this point there are several solutions.
I could not install python-numpy through apt. However, this causes issues because python-numpy installs a few different packages as requirements, and I do not know if another part of the system relies on these packages. And in reality, there are several apt packages installed through the Dockerfile, and each one I remove seems to reveal another Cannot uninstall X error, and removes a number of other packages along with it, that our app may or may not rely on.
I could also use the --ignore-installed option when I try to pip install things that have already been installed through apt, but then again I have the same problem of every --ignore-installed argument revealing yet another thing that needs to be ignored.
I could pin pip at an older version that does not have this restriction, but I don't want to be stuck using an outdated version of pip forever.
I have been going around in circles trying to come up with a good solution that involves minimal changes to this legacy Dockerfile, and allows the app we deploy with that file to continue to function as it has been. Any suggestions as to how I can safely get around this problem of pip 10 not being able to install newer versions of distutils packages? Thank you!
UPDATE:
I did not realize that --ignore-installed could be used without a package as an argument to ignore all installed packages. I am considering whether or not this might be a good option for me, and have asked about it here.
This is the solution I ended up going with, and our apps have been running in production without any issues for close to a month with this fix in place:
All I had to do was to add
--ignore-installed
to the pip install lines in my dockerfile that were raising errors. Using the same dockerfile example from my original question, the fixed dockerfile would look something like:
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install \
python-pip \
python-numpy # ...and many other packages
RUN pip install -U pip
RUN pip install -r /tmp/requirements1.txt --ignore-installed # don't try to uninstall existing packages, e.g., numpy
RUN pip install -r /tmp/requirements2.txt
RUN pip install -r /tmp/requirements3.txt
The documentation I could find for --ignore-installed was unclear in my opinion (pip install --help simply says "Ignore the installed packages (reinstalling instead)."), and I asked about the potential dangers of this flag here, but have yet to get satisfying answer. However, if there are any negative side effects, our production environment has yet to see the effects of them, and I think the risk is low/none (at least that has been our experience). I was able to confirm that in our case, when this flag was used, the existing installation was not uninstalled, but that the newer installation was always used.
Update:
I wanted to highlight this answer by #ivan_pozdeev. He provides some information that this answer does not include, and he also outlines some potential side-effects of my solution.
This is what worked for me--
pip install --ignore-installed <Your package name>
or
sudo pip install --ignore-installed <Your package name>
or (inside jupyter notebook)
import sys
!{sys.executable} -m pip install --ignore-installed <Your package name>
For windows
write
conda update --all
pip install --upgrade <Your package name>
OR
conda update --all
pip install <Your package name>
OR
pip install wrapt --upgrade --ignore-installed
pip install <Your package name>
from ERROR: Cannot uninstall 'wrapt'. during upgrade
You can just remove numpy manually but keep the other dependencies installed by apt. Then use pip as before to install the latest version of numpy.
#Manually remove just numpy installed by distutils
RUN rm /usr/lib/python2.7/dist-packages/numpy-1.8.2.egg-info
RUN rm -r /usr/lib/python2.7/dist-packages/numpy
RUN pip install -U pip
RUN pip install -r /tmp/requirements1.txt
The location of numpy should be the same. But if you want to confirm the location you can run the container without running the requirements.txt files and issue the following commands in the python console inside the container.
>>> import numpy
>>> print numpy.__file__
/usr/lib/python2.7/dist-packages/numpy/__init__.pyc
I try to install PyICU but it require libicui18n.so.36
I dont know How to get it could you help me please...
If you are on Ubuntu, try installing the python-pyicu package, which should take care of any binary dependencies, instead of trying to install from the sources:
$ sudo apt-get install python-pyicu
Alternatively, if you really need to install from the source package (e.g. with pip install pyicu), you'll need to the libicu development package installed:
$ sudo apt-get install libicu-dev
I'm trying to install kivy, in the docs it says:
$ sudo apt-get install python-setuptools python-pygame python-opengl \
python-gst0.10 python-enchant gstreamer0.10-plugins-good cython python-dev \
build-essential libgl1-mesa-dev libgles2-mesa-dev
$ sudo easy_install kivy
But I don't want to use sudo I like to keep my projects organized in virtualenv, so how install the requirements without using sudo. apt-get install won't work unless i use sudo. and i can't find the requirements in pip. Lets say i want to install easy_install in virtualenv for example, how to do that?
I do not think you can get around installing kivy's dependent packages without sudo/root access.
Once you have them installed, follow steps outlined in Andrew's answer.
when you use virtualenv and start it running, you can use the easy_install / pip that is installed there. that doesn't require sudo because it installs directly to virtualenv.
in other words - it just works. have you tried it?
there's a simple example here http://www.arthurkoziel.com/2008/10/22/working-virtualenv/
sudo easy_install virtualenv (the last sudo you need)
virtualenv kivydir
source kivydir/bin/activate
easy_install kivy (installs to kivydir)
I've seen it documented that you can install a Github hosting Python package using pip via:
sudo pip install -e git+git://github.com/myuser/myproject.git#egg=myproject
However, this appears to install the package to the current working directory, which is almost never where is should be.
How do you instruct pip to install it into the standard Python package directory (e.g. on Ubuntu this is /usr/local/lib/python2.6/dist-packages)?
The -e flag tells pip to install it as "editable", i.e. keep the source around. Drop the -e flag and it should do about what you expect.
sudo pip install git+git://github.com/myuser/myproject.git#egg=myproject
If that doesn't work try using https instead of git.
sudo pip install git+https://github.com/myuser/myproject.git#egg=myproject
For Python 3 make sure you have python3-pip installed (and of course git installed):
The syntax just changed to:
sudo pip3 install git+git://github.com/someuser/someproject.git