Reinstalling python on CentOS to be able to use yum - python

I messed up big time and I removed the python package on a CentOS server. After then I realized yum was dependant on python and I could no longer use yum. I think I need to reinstall python to fix the problem. How can I do this without using yum?
I tried:
sudo wget
http://mirror.centos.org/centos/6/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm
then
sudo rpm -ivh python-2.6.6-51.el6.x86_64.rpm
but I'm getting the error:
error: Failed dependencies: python-libs(x86-64) = 2.6.6-51.el6 is
needed by python-2.6.6-51.el6.x86_64 python < 2.6.6-52.el6 conflicts
with python-devel-2.6.6-52.el6.x86_64
Please any suggestion?

I think you might need to download python-2.6.6-52.el6.x86_64.rpm instead.

rpm link is not working any more...
you can use the command in centOS for sudo user like:
sudo yum install http://mirror.centos.org/centos/6/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm
without dependencies:
sudo yum install --nodeps http://mirror.centos.org/centos/6/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm
You do not need to download it.

Try installing with --nodeps parameter.
# sudo rpm --nodeps -ivh python-2.6.6-51.el6.x86_64.rpm

Related

How to install rpm and dependencies on RHEL?

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.

How to install the pyautogui module on RedHat

I've been using the Python module pyautogui on Windows where it is fairly simple to install and need to install it on a RedHat server for work.
The official documentation gives the following instructions for Linux installation:
pip3 install python3-xlib
sudo apt-get install scrot
sudo apt-get install python3-tk
sudo apt-get install python3-dev
pip3 install pyautogui
Now, two things bother me with this:
1) It assumes using Python 3 but we're using Python 2. Does it imply that the module only exists for Python 3 in Linux? Because I have been using it for Python 2 on Windows.
2) Dependency-wise, it assumes using Debian's package manager APT, certainly these dependencies should be available on a RedHat system with yum.
I first decided to install python-xlib which is the Python 2 version of the first package and it worked.
Secondly I tried:
sudo yum install scrot
Which resulted in the error "No package Scrot available". Finding a dead-end this way, I tried to manually download the sources for Scrot and install it.
I followed the instructions:
$ wget http://linuxbrit.co.uk/downloads/scrot-0.8.tar.gz
$ tar -xvf scrot-0.8.tar.gz
$ cd /scrot-0.8
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
Which only resulted in getting the error
checking whether to enable maintainer-specific portions of Makefiles... no
checking for giblib-config... no
checking for giblib - version >= 1.2.3... no
*** The giblib-config script installed by giblib could not be found
*** If giblib was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GIBLIB_CONFIG environment variable to the
*** full path to giblib-config.
configure: error: Cannot find giblib: Is giblib-config in the path?
I found some threads addressing the issue and roughly asking to install giblib. However, I failed in doing so. Again, I only found instructions to install it in Debian-like systems and could not find out how to install it on a RedHat system. So now I'm trying to download and install the sources of giblib but this is beginning messy, especially given the fact that I'll have to ask that pyautogui to be installed on our production servers and I don't see myself explaining to my boss such a tremendous and bulky procedure. That would get rejected right away.
So I am now asking for help, a perhaps better or easier way to install the Python pyautogui moduke for Python 2 on a RedHat system. Or maybe even a similar module, I could not find any, as simple and efficient to use, alternative.
If someone could help me on this, that would be really helpful and would save me a lot of work and dead-ends.
I was facing the exact same issue, got into a loop of missing dependencies. Finally, someone helped me out, and it works.
yum install epel-release
yum install wget imlib2
wget http://packages.psychotic.ninja/7/base/x86_64/RPMS/scrot-0.8-12.el7.psychotic.x86_64.rpm
wget http://packages.psychotic.ninja/7/base/x86_64/RPMS/giblib-1.2.4-22.el7.psychotic.x86_64.rpm
rpm -Uvh giblib-1.2.4-22.el7.psychotic.x86_64.rpm
rpm -Uvh scrot-0.8-12.el7.psychotic.x86_64.rpm
And that's it. I was able to use PyAutoGUI after this.
I got scrot installed to Centos7 with following steps:
https://pkgs.org/:
Download & install:
giblib-devel-1.2.4-22.el7.psychotic.x86_64.rpm
giblib-1.2.4-22.el7.psychotic.x86_64.rpm
sudo yum --nogpgcheck localinstall
http://scrot.sourcearchive.com/downloads/0.8-8/:
Download:
scrot_0.8.orig.tar.gz
Install:
tar xvf scrot_0.8.orig.tar.gz
cd scrot-0.8/
./configure
make
sudo make install
I had a problem with Xlib in the install of PyAutoGUI with python 3 and somehow I managed to solve that problem and I want to share that here based on the question title "install the PyAutoGUI on linux RedHat"
error of installing PyAutoGUI with python 3 is something like this
Xlib.error.XauthError: ~/.Xauthority: [Error 2] No such file or directory: '/home/username/.Xauthority'
to install PyAutoGUI without error:
way 1 __
first, install Xlib
sudo yum install libX11
after that install this tow package
pip install PyUserInput
pip install PyAutoGUI
if that did not work for you, install python3-xlib before PyUserInput & PyAutoGUI
pip install python3-xlib
way 2 __
download (xvfb-run) from pkgs.org and install that with following command
rpm -ivh yourfile.rpm
then with help of xvfb-run you can install and even use PyAutoGUI code without error...
xvfb-run pip install PyAutoGUI
way 3 __
install one of this ( python3-xlib || python-xlib )
pip install python3-xlib
and then
export DISPLAY=:0
pip install PyAutoGUI

How to get libicui18n.so.36 ?

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

ImportError: No module named psycopg2

In installation process of OpenERP 6, I want to generate a config file with these commands:
cd /home/openerp/openerp-server/bin/
./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-server.cfg
But it always showed the message: ImportError: No module named psycopg2
When I checked for psycopg2 package, it's already installed. Package python-psycopg2-2.4.5-1.rhel5.x86_64 is already installed to its latest version. Nothing to do. What's wrong with this? My server is CentOS, I've installed Python 2.6.7.
Step 1: Install the dependencies
sudo apt-get install build-dep python-psycopg2
Step 2: Run this command in your virtualenv
pip install psycopg2-binary
Ref: Fernando Munoz
Use psycopg2-binary instead of psycopg2.
pip install psycopg2-binary
Or you will get the warning below:
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
Reference: Psycopg 2.7.4 released | Psycopg
I faced the same issue and resolved it with following commands:
sudo apt-get install libpq-dev
pip install psycopg2
Try installing
psycopg2-binary
with
pip install psycopg2-binary --user
Please try to run the command import psycopg2 on the python console. If you get the error then check the sys.path where the python look for the install module. If the parent directory of the python-psycopg2-2.4.5-1.rhel5.x86_64 is there in the sys.path or not. If its not in the sys.path then run export PYTHONPATH=<parent directory of python-psycopg2-2.4.5-1.rhel5.x86_64> before running the openerp server.
Import Error on Mac OS
If psycopg2 is getting installed but you are unable to import it in your .py file then the problem is libpq, its linkages, and the library openssl, on which libpq depends upon. The overall steps are reproduced below. You can check it step by step to know which is the source of error for you and then you can troubleshoot from there.
Check for the installation of the openssl and make sure it's working.
Check for installation of libpq in your system it may not have been installed or not linked. If not installed then install it using the command brew install libpq. This installs libpq library. As per the documentation
libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.
Link libpq using brew link libpq, if this doesn't work then use the command: brew link libpq --force.
Also put in your .zshrc file the following export PATH="/usr/local/opt/libpq/bin:$PATH". This creates all the necessary linkages for libpq library .
Now restart the terminal or use the following command source ~/.zshrc.
Now use the command pip install psycopg2. It will work.
This works, even when you are working in conda environment.
N.B. pip install psycopg2-binaryshould be avoided because as per the developers of the psycopg2 library
The use of the -binary packages in production is discouraged because in the past they proved unreliable in multithread environments. This might have been fixed in more recent versions but I have never managed to reproduce the failure.
Try with these:
virtualenv -p /usr/bin/python3 test_env
source test_env/bin/activate
pip install psycopg2
run python and try to import if you insist on installing it on your systems python try:
pip3 install psycopg2
Recently faced this issue on my production server. I had installed pyscopg2 using
sudo pip install psycopg2
It worked beautifully on my local, but had me for a run on my ec2 server.
sudo python -m pip install psycopg2
The above command worked for me there. Posting here just in case it would help someone in future.
sudo pip install psycopg2-binary
You need to install the psycopg2 module.
On CentOS:
Make sure Python 2.7+ is installed. If not, follow these instructions: http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
# Python 2.7.6:
$ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
$ tar xf Python-2.7.6.tar.xz
$ cd Python-2.7.6
$ ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
$ make && make altinstall
$ yum install postgresql-libs
# First get the setup script for Setuptools:
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7 and/or Python 3.3:
$ python2.7 ez_setup.py
$ easy_install-2.7 psycopg2
Even though this is a CentOS question, here are the instructions for Ubuntu:
$ sudo apt-get install python3-pip python-distribute python-dev
$ easy_install psycopg2
Cite: http://initd.org/psycopg/install/
For python3 on ubuntu, this worked for me:
$sudo apt-get update
$sudo apt-get install libpq-dev
$sudo pip3 install psycopg2-binary
i have the same problem, but this piece of snippet alone solved my problem.
pip install psycopg2
Run into the same issue when I switch to Ubuntu from Windows 10.. the following worked for me.. this after googling and trying numerous suggestions for 2 hours...
sudo apt-get install libpq-dev
then
pip3 install psycopg2
I hope this helps someone who has encountered the same problem especially when switching for windows OS to Linux(Ubuntu).
I have done 2 things to solve this issue:
use Python 3.6 instead of 3.8.
change Django version to 2.2 (may be working with some higher but I change to 2.2)
For Python3
Step 1: Install Dependencies
sudo apt-get install python3 python-dev python3-dev
Step 2: Install
pip install psycopg2
check correctly if you had ON your virtual env of your peoject, if it's OFF then make it ON. execute following cammands:
workon <your_env_name>
python manage.py runserver
It's working for me
It's very simple, not sure why nobody mentioned this for mac before.
brew install postgresql
pip3 install psycopg2
In simple terms, psycopg2 wants us to install postgres first.
PS: Don't forget to upvote, so that it can help other people as well.
Solved the issue with below solution :
Basically the issue due to _bz2.cpython-36m-x86_64-linux-gnu.so Linux package file. Try to find the the location.
Check the install python location ( which python3)- Example: /usr/local/bin/python3
copy the file under INSTALL_LOCATION/lib/python3.6
cp -rvp /usr/lib64/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so /usr/local/lib/python3.6
try:
pip install psycopg2 --force-reinstall --no-cache-dir
Python2 importerror no module named psycopg2
pip install psycopg2-binary
Requirement already satisfied...
Solved by following steps:
sudo curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo python -m pip install psycopg2-binary
pip install psycopg-binary
The line above helped me
For Python3 use this:
sudo apt-get install -y python3-psycopg2

Error: No module named psycopg2.extensions

I am trying to set up a PostgreSQL database for my django project, which I believe I have done now thanks to the replies to my last question Problems setting up a postgreSQL database for a django project. I am now trying to run the command 'python manage.py runserver' in Terminal to get my localhost up but when I run the command, I see this response...
Error: No module named psycopg2.extensions
I'm not sure what this means - I have tried to download psycopg2 but can't seem to find a way to download psycopg2 using homebrew. I have tried easy_install, pip install and sudo but all return errors like this...
Downloading http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.5.tar.gz
Processing psycopg2-2.4.5.tar.gz
Writing /tmp/easy_install-l7Qi62/psycopg2-2.4.5/setup.cfg
Running psycopg2-2.4.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-l7Qi62/psycopg2-2.4.5/egg-dist-tmp-PBP5Ds
no previously-included directories found matching 'doc/src/_build'
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1
How to fix this?
The first thing to do is to install the dependencies.
sudo apt-get build-dep python-psycopg2
sudo apt install python3-psycopg2 # Python 3
After that go inside your virtualenv and use:
pip install psycopg2-binary
These two commands should solve the problem.
pip install psycopg2-binary
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
For Django 2 and python 3 install psycopg2 using pip3 :
pip3 install psycopg2
I installed it successfully using these commands:
sudo apt-get install libpq-dev python-dev
pip install psycopg2
For macOS Mojave just run pip install psycopg2-binary. Works fine for me, python version -> Python 3.7.2
first install apt-get install python-setuptools
then try easy_install psycopg2
This is what helped me on Ubuntu if your python installed from Ubuntu installer. I did this after unsuccessfully trying 'apt-get install' and 'pip install':
In terminal:
sudo synaptic
then in synaptic searchfield write
psycopg2
choose
python-psycopg2
mark it for installation using mouse right-click and push 'apply'. Of course, if you don't have installed synaptic, then first do:
sudo apt-get install synaptic
I ran into this same issues recently and this code worked.
sudo apt-get install libpq-dev python-dev-is-python3
Then
pip3 install psycopg2
In python 3.4, while in a virtual environment, make sure you have the build dependencies first:
sudo apt-get build-dep python3-psycopg2
Then install it:
pip install psycopg2
On Alpine Linux (majority of the docker containers) do:
apk add postgresql-dev
Then:
pip install psycopg2-binary
pip3 install django-psycopg2-extension
I know i am late and there's lot of answers up here which also solves the problem. But today i also faced this problem and none of this helps me. Then i found the above magical command which solves my problem :-P . so i am posting this as it might be case for you too.
Happy coding.
I used the extension after only importing psycopg2:
import psycopg2
...
psycopg2.extensions.AsIs(anap[i])
It seems that you need gcc-4.0, and it would be helpful to specify your OS type and version.
Maybe this question will help you a bit: Installing GCC to Mac OS X Leopard without installing Xcode
Update
I'm a Windows user, so I can't test your setup, but a quick google pointed to some more links:
http://hardlifeofapo.com/psycopg2-and-postgresql-9-1-on-snow-leopard/
Cannot install psycopg2 on OSX 10.6.7 with XCode4
I encountered the No module named psycopg2.extensions error when trying to run pip2 install psycopg2 on a Mac running Mavericks (10.9). I don't think my stack trace included a message about gcc, and it also included a hint:
Error: pg_config executable not found.
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'.
I looked for the pg_config file in my Postgres install and added the folder containing it to my path: /Applications/Postgres.app/Contents/Versions/9.4/bin. Your path may be different, especially if you have a different version of Postgres installed - I would just poke around until you find the bin/ folder. After doing this, the installation worked.
try this: sudo pip install -i https://testpypi.python.org/pypi psycopg2==2.7b2
.. this is especially helpful if you're running into egg error
on aws ec2 instances if you run into gcc error; try this
1. sudo yum install gcc python-setuptools python-devel postgresql-devel
2. sudo su -
3. sudo pip install psycopg2
This one worked for me
python manage.py migrate
I had such problem when trying to run python script as a sudo, while psycopg2 was installed via pip3 to my own user's directory.
I managed to resolve the issue for myself removing pip3 version, and just installing it via apt:
pip3 uninstall psycopg2
sudo apt install python3-psycopg2
you can install gcc for macos from https://github.com/kennethreitz/osx-gcc-installer
after instalation of gcc you'll be able to install psycopg with easy_install or with pip
Check if you have installed psycopg2 if not
sudo apt-get install psycopg2
Install the dependencies.
sudo apt-get build-dep python-psycopg2
These two commands should solve the problem.
This error raise because you not install postgres database in you project virtutal environment. you should run one of these command.
from a terminal you can you command for sudo.
sudo apt-get install build-dep python-psycopg2
for pip (pip basically work for python)
pip install psycopg2
or
pip3 install psycopg2-binary
i'm pretty sure it will work for you.

Categories

Resources