Python3 pip3 can't install requests - python

On my Ubuntu 16.04 Desktop I have python2.7.12 and python3.6.1 installed.
seept#seept:~$ python --version
Python 2.7.12
seept#seept:~$ python3 --version
Python 3.6.1
And I also installed pip and pip3. Is it true that pip is for python2 and pip3 is for python3?
So why the hell both versions of pip shows me this:
seept#seept:~$ pip --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)
seept#seept:~$ pip3 --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)
Why Python 3.5?
seept#seept:~$ which python
/usr/bin/python
seept#seept:~$ which python3
/usr/local/bin/python3
seept#seept:~$ which pip
/home/seept/.local/bin/pip
seept#seept:~$ which pip3
/home/seept/.local/bin/pip3
So my real problem is that I need the module 'requests' for a python3 project.
When I run:
seept#seept:~$ sudo pip3 install requests
This is the output:
The directory '/home/seept/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/seept/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
**Requirement already satisfied: requests in ./.local/lib/python3.5/site-packages**
By the way I always get this message:
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So this output says I am using pip verison 8.1.1 but when I run pip --version it says me I am running version 9.0.1.
For me it looks like I already messed it up and should reinstall all?

You should run your project with virtualenv. It keeps safe your project directory and avoids conflict with other versions well.
Go to your project directory and just install first virtualenv using:
pip install virtualenv
Before installing your packages run this to activate virtualenv:
source venv/bin/activate
Now your directory is safe and you can install your package here to remain safe and unique from another directory.
Hope you understand my concept.
Thanks.

Related

When i run pip3 freeze or pip3 list there is no output

As the title says, when i run pip3 freeze or pip3 list there is no output on the terminal!
Virtualenv seems also to be broken cause when i was inside of the env it was using the global django-admin.
I did sudo pip3 install --upgrade pip and after that i think it broke.
OS: Manjaro Linux
Python3 Version: Python 3.7.4
Pip3 Version: pip
19.2.3 from /usr/lib/python3.7/site-packages/pip (python 3.7)
Find out how to cleanly reinstall pip (or even Python) from your operating system and really try to avoid anything with sudo pip or even sudo python. My recommendation is to not even install pip at all and use the one preinstalled in the virtual environments (when you do python3 -m venv .venv) instead, this is to avoid any conflict with the Python packages installed by your operating system.

pip freeze gives different version from pip --version

I am on Windows 10 and just installed Python 3.7.4. I installed virtualenv using pip install virtualenv, and i got the message that i installed 16.7.2 while 19.2.1 is available. I then used python -m pip install --upgrade pip to upgrade.
Here is the issue: when i type pip freeze on Powershell, i am getting this:
virtualenv==16.7.2
but when i type pip --version, i am getting this:
pip 19.2.1 from c:\users\user1\python\lib\site-packages\pip (python 3.7)
Can you please let me know why pip freeze still shows the old version?
Thanks.
pip and virtualenv are 2 different cases where pip is mainly used for installing python packages and virtualenv for utilizing virtual environments while development.
The following command updates only pip not virtual env
python -m pip install --upgrade pip
If you think you still need to upgrade virtualenv (of course if a new version is available). Please follow the following syntax without specifying a version.
pip install [package] --upgrade

OSX pip always uses Python2.7 and ignores my 3.6 install

I installed pip through brew, and I can't get it to use python 3 instead of 2.7. Here's the information I think might be relevant to demonstrate what's happening.
$ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip2 -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip3 -V
-bash: pip3: command not found
$ which pip
/usr/local/bin/pip
$ sudo python3 get-pip.py
The directory '/Users/tj/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/tj/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: pip in /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
$ sudo easy_install3 pip
sudo: easy_install3: command not found
$ sudo easy_install-3.6 pip
sudo: easy_install-3.6: command not found
$ sudo easy_install pip
Searching for pip
Best match: pip 9.0.1
Processing pip-9.0.1-py2.7.egg
pip 9.0.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
I tried everything I could find online with no luck. The main symptom of this problem is when I use pip to install a package, it always goes into 2.7 (or fails to install because numpy is deprecated or something like that).
On OSX, brew (or other) python 2.7/3 is installed separately to the older version of 2.7 that comes with OSX. Trust me when I say you DO NOT WANT TO MESS WITH IT.
Try typing pip3
$ pip3 --version
$ pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
Whereas pip (for 2.7) is not even installed.,
$ pip --version
$ zsh: command not found: pip
Even if you try:
$ brew install pip
Leads to
If you meant "pip" specifically:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
AS A LAST RESORT:
python3 -m ensurepip
will ensure/fix a system has it.
pip3 should be located at /usr/local/bin/pip3
Contents are:
#!/usr/local/opt/python3/bin/python3.6
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==9.0.1','console_scripts','pip3'
__requires__ = 'pip==9.0.1'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
)

Installing pip in Pycharm 2016.3

I upgraded to the new version of Pycharm. In the terminal, it says bash-3.2$ instead of my username. When I tried to install a library, it said that pip command is not found:
bash: pip: command not found
So I installed pip:
bash-3.2$ sudo easy_install pip
Searching for pip
Best match: pip 8.1.2
pip 8.1.2 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Using /Library/Python/2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip</i>
Okay, now all I have to do is use pip to install a library, right?
But then, this happens:
bash-3.2$ pip install pandas
bash: pip: command not found
I don't understand what I have to do to actually install pip. Or should I use sudo easy_install [library]?
I know that this is not precisely what you're asking, but PyCharm has its own built-in package manager. You should not have to use pip manually.
File->Settings->Project Interpreter
https://www.jetbrains.com/help/pycharm/2016.3/installing-uninstalling-and-upgrading-packages.html
there you can manage the installed packages for the selected Python interpreter or virtualenv.
Run this command on your terminal. pip will be installed without any issue.
sudo [your package manager] install python-pip python-dev build-essential
If it is not solved. The problem might be PATH problem.
Type echo $PATH on terminal. There should be /usr/local/bin in the output. If it is not type PATH=$PATH:/usr/local/bin to add /usr/local/bin to PATH

pyvenv installs wrong pip version

I'm creating a virtualenv with pyvenv env but the installed pip version is outdated. I can manually update pip in the virtual env but I would like to have the correct version automatically.
Without venv activated:
~> pip -V
pip 7.1.2 from /usr/lib/python3.4/site-packages (python 3.4)
Installing the venv:
~> pyvenv env
~> source env/bin/activate.fish
With venv activated:
~> pip -V
pip 6.0.8 from /home/syntonym/test/env/lib/python3.4/site-packages (python 3.4)
I'm using arch and have pip managed by both, pip and pacman (the arch packet manager), which is probably not a good idea. I still have no idea from where pyvenv gets a 6.0.8 version of pip or how to fix it. Reinstalling with pacman did not help.
EDIT:
ensurepip claims it's already up to date:
~> python -m ensurepip --upgrade
Ignoring indexes: https://pypi.python.org/simple
Requirement already up-to-date: setuptools in /usr/lib/python3.4/site-packages
Requirement already up-to-date: pip in /usr/lib/python3.4/site-packages
You can upgrade pip in a virtual environment manually by executing
pip install -U pip
You are facing this problem, because venv uses ensurepip to add pip into new environments:
Unless the --without-pip option is given, ensurepip will be invoked to
bootstrap pip into the virtual environment.
Ensurepip package won't download from the internet or grab files from anywhere else, because all required components are already included into the package. Doing so would add security flaws and is thus unsupported.
Ensurepip is not designed to give you the newest pip, but just "a" pip. To get the newest one use the manual way at the beginning of this post.

Categories

Resources