latest version of psycopg2 on aws - amazon-ec2

I am trying to get the latest version of psycopg2 on my aws instance. I noticed that the latest version was 2.4.6 but I could only get 2.0.14 on aws. Is there a way to get the latest version? There are some features I need that are not supported in the earlier versions.

This works for me in Amazon aws-cli/1.9.11 Python/2.7.10 Linux/4.1.10 and Ubuntu 14
If pip not installed in your Amazon AWS machine type:
$ sudo yum install python-pip
and then type below commands:
$ sudo yum update
$ sudo yum install libpq-dev python-dev
$ sudo pip install psycopg2
Then you will get message like below :
You are using pip version 6.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting psycopg2
Downloading psycopg2-2.6.1.tar.gz (371kB)
100% |████████████████████████████████| 372kB 1.3MB/s
Installing collected packages: psycopg2
Running setup.py install for psycopg2
Successfully installed psycopg2-2.6.1
If pip not installed in your Ubuntu machine type:
$ sudo apt-get install python-pip
and then type below commands:
$ sudo apt-get update
$ sudo apt-get install libpq-dev python-dev
$ sudo pip install psycopg2
Then you will get message like below :
You are using pip version 6.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting psycopg2
Downloading psycopg2-2.6.1.tar.gz (371kB)
100% |████████████████████████████████| 372kB 1.3MB/s
Installing collected packages: psycopg2
Running setup.py install for psycopg2
Successfully installed psycopg2-2.6.1

If you need a more recent version of psycopg2 on your EC2 instance, you can install it directly with pip using: $ pip install psycopg2
You may need to first install the python-dev and libpq-dev libraries as explained in this StackOverflow question.

Working answer as of November 2022:
sudo yum install postgresql-devel python3-devel
pip install wheel
pip install psycopg2
If you are still using Python 2 then use python-devel instead of python3-devel.
The pip install wheel is not strictly necessary, but psycopg2 prefers it and it wasn't installed yet in my environment.

Related

Why I can't pip install nltk on mac os?

I'm using mac os mojave, install python 2.7 and install pip using python get-pip.py, I already try those command to install pip :
pip install --upgrade pip
pip install nltk
and try
sudo python -m pip install --upgrade nltk
But also result to same error like in this image
Or here in text:
error in nltk setup command: 'install_requires' must be a string or
list of strings containing valid project/version requirement
specifiers; Expected version spec in singledispatch; python_version <
"3.4" at ; python_version < "3.4"
Is it because my python version (2.7) ? But in pip ntlk page it says also support 2.7
update:
pip install nltk success after running :
pip install --upgrade setuptools pip --user
Start with upgrading installation tools:
pip install --upgrade setuptools pip

How to uninstall Airflow?

I am a newbie to Airflow. i have some trouble to remove Airflow v1.10.3 ,i am using pip3 version 8.1.1 on Ubuntu 16.04.
I already tried to remove pip with sudo apt-get remove python3-pip
and sudo apt-get remove pip3 and all his dependencies.
and tried to remove all libraries related with Python.
But i stil have Airflow and his commands down in terminal.
If you are not able to uninstall with
pip uninstall airflow
Maybe the reason is for the latest versions of Airflow this command will work
pip uninstall apache-airflow
Credits to This Answer.
The command apt-get remove pip doesn't remove pip-installed libraries.To uninstall pip-installed libraries you need to install pip back and then uninstall the libraries using pip:
sudo apt install pip # or pip3
pip uninstall airflow
or
pip3 uninstall airflow
depending on what python version you use.

How do you upgrade version of pip on Repl.it?

I'm having issues upgrading pip using the pip3 install --upgrade pip3 command on Repl.it and getting this error:
Repl.it: Installing fresh packages
Usage: pip3 [options]
pip3: error: no such option: --upgrade
You are using pip version 9.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Repl.it: package installation failed!
How can I upgrade pip on Repl.it?

Wrong python version for Elastic Beanstalk

I initially installed Elastic Beanstalk (via $ pip install awsebcli) using Python 2. I want to make sure my application will be deployed with Python 3. I tried uninstalling Elastic Beanstalk ($ pip uninstall awsebcli) and reinstalling it, but when I run $ eb -- version I still get EB CLI 3.12.1 (Python 2.7.1).
I know this question is a few months old but I thought I'd add a clarified answer since I just encountered this.
The Problem
I was trying to install the awsebcli with the python2 version of pip.
If you run pip --version it'll tell you:
$ pip --version
pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
The Solution
What you need it to install pip from python3-pip and use the pip3 command.
First of course if you've installed the awsebcli with this pip version you'll want to remove it.
$ pip uninstall awsebcli
Now install the new python3 version of pip:
$ sudo apt-get install python3-pip
This will make the pip3 command available which manages python3 libraries.
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
Next install the awsebcli with pip3
$ pip3 install awsebcli
Finally check that you've got the right eb version:
$ eb --version
EB CLI 3.14.4 (Python 3.6.5)

How to install pip in CentOS 7?

CentOS 7 EPEL now includes Python 3.4: yum install python34
However, when I try that, even though Python 3.4 installs successfully, it doesn't appear to install pip. Which is weird, because pip should be included by default with Python 3.4. which pip3 doesn't find anything, nor does which pip.
How do I access pip from the Python 3.4 package in CentOS 7 EPEL release?
The easiest way I've found to install pip3 (for python3.x packages) on CentOS 7 is:
$ sudo yum install python34-setuptools
$ sudo easy_install-3.4 pip
You'll need to have the EPEL repository enabled before hand, of course.
You should now be able to run commands like the following to install packages for python3.x:
$ pip3 install foo
curl https://bootstrap.pypa.io/get-pip.py | python3.4
Or if you don't have curl for some reason:
wget https://bootstrap.pypa.io/get-pip.py
python3.4 get-pip.py
After this you should be able to run
$ pip3
The CentOS 7 yum package for python34 does include the ensurepip module, but for some reason is missing the setuptools and pip files that should be a part of that module. To fix, download the latest wheels from PyPI into the module's _bundled directory (/lib64/python3.4/ensurepip/_bundled/):
setuptools-18.4-py2.py3-none-any.whl
pip-7.1.2-py2.py3-none-any.whl
then edit __init__.py to match the downloaded versions:
_SETUPTOOLS_VERSION = "18.4"
_PIP_VERSION = "7.1.2"
after which python3.4 -m ensurepip works as intended. Ensurepip is invoked automatically every time you create a virtual environment, for example:
pyvenv-3.4 py3
source py3/bin/activate
Hopefully RH will fix the broken Python3.4 yum package so that manual patching isn't needed.
Update: The python34 bug mentioned below has finally been fixed. It is a perfectly fine choice now.
Rather than using broken EPEL python34 packages, you can enable the IUS repo and have it work properly.
pip inside virtual environments
The main python34u and python35u IUS packages include the pyvenv tool (/usr/bin/pyvenv-3.4 or /usr/bin/pyvenv-3.5) that includes bundled wheels of pip and setuptools for bootstrapping virtual environments.
global pip
The python34u-pip and python35u-pip IUS packages include /usr/bin/pip3.4 and /usr/bin/pip3.5 respectively. These work just fine to install packages to the system site-packages directory.
yum install python34-pip
pip3.4 install foo
You will likely need the EPEL repositories installed:
yum install -y epel-release
Update 2019
I tried easy_install at first but it doesn't install packages in a clean and intuitive way. Also when it comes time to remove packages it left a lot of artifacts that needed to be cleaned up.
sudo yum install epel-release
sudo yum install python34-pip
pip install package
Was the solution that worked for me, it installs "pip3" as pip on the system. It also uses standard rpm structure so it clean in its removal. I am not sure what process you would need to take if you want both python2 and python3 package manager on your system.
Below are the steps I followed to install python34 and pip
yum update -y
yum -y install yum-utils
yum -y groupinstall development
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum makecache
yum -y install python34u python34u-pip
python3.6 -v
echo "alias python=/usr/bin/python3.4" >> ~/.bash_profile
source ~/.bash_profile
pip3 install --upgrade pip
# if yum install python34u-pip doesnt work, try
curl https://bootstrap.pypa.io/get-pip.py | python
There is a easy way of doing this by just using easy_install (A Setuptools to package python librarie).
Assumption.
Before doing this check whether you have python installed into your Centos machine (at least 2.x).
Steps to install pip.
So lets do install easy_install,
sudo yum install python-setuptools python-setuptools-devel
Now lets do pip with easy_install,
sudo easy_install pip
That's Great. Now you have pip :)
Figure out what version of python3 you have installed:
yum search pip
and then install the best match. Use reqoquery to find name of resulting pip3.e.g
repoquery -l python36u-pip
tells me to use pip3.6 instead of pip3
On CentOS 7, the pip version is pip3.4 and is located here:
/usr/local/bin/pip3.4

Resources