Wrong python version for Elastic Beanstalk - pip

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)

Related

even after using pip update command, the version remains the same

I was just trying to download packages using pip in the terminal in pycharm and there was a notice from pip saying "You are using pip version 10.0.1, however, version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command."
I ran the command but when I typed "pip -V" to check the version, it remained the same 10.0.1. And when I run the command, it says that pip is already up to date
How can solve this?
Your python and pip seem to point to different python versions. Check by typing which python or where python in the terminal.
To make sure they match, you can use
python -m pip install --upgrade pip (as you did) for upgrading
python -m pip install <package name> for installation

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.

Why is PIP raising an AssertionError on pip freeze?

My console:
desarrollador#desarrollador-HP-14-Notebook-PC1:~$ pip freeze
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/freeze.py", line 68, in run
req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags)
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 156, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
I installed the tornado package and this happened since. How can I fix it?
This worked for me (running Ubuntu, both 12 and 14 LTS):
pip install -U setuptools
pip install -U pip
Upgrade to the latest version of setuptools in order to be able to upgrade to the latest version of pip, and upgrade to the latest version of pip to get a version that has fixed the AssertException error.
Reason: The python-pip package in Ubuntu 12.04 is seriously outdated and has some bugs with certain package names (as I can see) and cannot parse them correctly.
Solution: install a newer version of pip, via easy_install.
Your pip may be outdated. Even in Ubuntu 14.04 LTS, the pip version it installed using apt-get install python-pip was 1.5.4. Try updating pip manually, and possibly the new packages again as well.
pip --version # 1.5.4
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
pip --version # 6.0.8
hash -r # reset bash cache
https://pip.pypa.io/en/latest/installing.html
I found the solution at this link.
pip install setuptools==7.0
First, I ran Martin Mohan's solution:
/usr/local/bin/pip uninstall pip
apt-get remove python-pip
apt-get install python-pip
Then, boredcoding's ultimately fixed the problem, both solutions are found near bottom of thread: I screwed up the system version of Python Pip on Ubuntu 12.10
$apt-get install python-pip
$which pip
/usr/bin/pip
$pip install -U pip
$which pip
/usr/bin/pip
$hash -r
$which pip
/usr/local/bin/pip
The logic behind these two fix are stated in the thread (linked above), so I will refrain from going into each here.
The problem is due to an old version of pip being installed.
Run the following command to install a new version of pip:
sudo easy_install -U pip.
It may be a bit late, but one thing I found was there are 2 or three versions of pip installed (depending on what you installed)
pip - the OS version installed, freeze doesn't work and it can be out of date
pip2 - the newer one installed but upgrading pip via pip etc
pip3 - installed if you have python3 and python2 installed at the same time.
You can either change which pip gets used in $PATH, or do what I did:
pip2 freeze (which does work on ubuntu14 if you have more than one option for python)

latest version of psycopg2 on aws

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.

I have installed virtualenv 1.9 which includes pip, but cannot install nltk

I have installed virtualenv 1.9 which includes pip, but cannot install nltk on my Mac. First it does not recognize pip as a command. Second how do I install nltk?
You should be able to run the following command to setup the virtual environment:
$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools.............done.
Installing pip...............done.
Then activate the virtual environment using:
$ source venv/bin/activate
Then install nltk:
(venv)$ pip install nltk
When you are done with the virtual environment run:
$ deactivate
You may want to try installing Python using Homebrew rather than using the Python version included with the OS. With 'brew' you will not need to use virtualenv (unless you want to) because brew installs packages to /usr/local owned by you. So you can simply run 'pip install '.
Follow the installation instructions here for Homebrew. Then run:
$ brew install python
$ pip install nltk
You can install virtualenv as well if you want it.
$ pip install virtualenv

Resources