pip install pathlib - python-2.7

I work with python 2.7.8 and can't change the version of python because it affect other important programs. Continuously to Unzip zip files in folders and subfolders with python i don't know how to install "pip install pathlib". Any help would be great.

If on windows, type this from Command Prompt to get pathlib for Python 2.7.8:
python -m pip install pathlib2
If you're on a unix distro, type this from BASH (any shell):
pip install pathlib2
If on mac, from terminal:
sudo easy_install pip
pip install pathlib2
And now you should be able to import pathlib2 (backported version of pathlib) from Python 2.7.8.

i succeed install pathlib2 module by enter into the cmd.exe and writing:
cd C:\Users\jon\AppData\Local\Programs\Python\Python38-32\Scripts pip install pathlib2

Related

Why is "-m" needed for "python -m pip install ..."?

I recently used pip to install the requests package in python 2.7, however in order to do so I had to use:
python -m pip install requests
instead of just:
python pip install requests
which gave me an error:
can't open file 'pip: [Errno 2] No such file or directory
Why did I need to add the -m?
python -m pip tells python to run with the pip module as the main module.
python pip isn't understood, because pip isn't a command line argument that python understands (i.e., pip is a module).
If the python scripts directory (c:\python27\scripts for python 2.7 on windows) is on your path, then you can just run pip (without python before it) and pass the same options you would pass to python -m pip.
So: you need to add -m pip so python knows what module to use as the main module. pip is a standalone program installed in your python scripts directory, not an argument to python.

How can I install autopep8 tool in Spyder in Anaconda?

I have Anaconda2, which come with Spyder.
I want to install an autopep8 for Spyder but I don't know which and how
Normally you can install it using:
pip install spyder.autopep8
So in anaconda (apparently there is no conda build for sypder.autopep8 ) so you just need to make sure you have pip installed in your conda environment and then use pip to install it:
conda install pip
pip install spyder.autopep8
or if you want to install it directly from the github repo:
pip install git+ssh://git#github.com/spyder-ide/spyder-autopep8
If you install directly from git, there is not way for it to give you a distribution not found error.
After that do shift+F8 in spyder to autopep8.
Otherwise, if you are using a .yml file for your conda environment, you just need to add
- pip
- pip:
- git+ssh://git#github.com/spyder-ide/spyder-autopep8
to your environment file and then run
conda env update -f environment.yml
from the command line.

pip command by default using python 3...how to change it to python 2?

I am using macOS Sierra 10.12 and after I upgraded my OS I can no longer install packages for python 3 using pip. Before I used to use pip for python2 and pip3 for python 3 as I have both versions of Python. But now I can no longer use pip to install libraries for python2.
Can anyone help me how can I change my default pip installer to python2? So that I can just use pip install in order to install for python 2.
For your information - when I only type python on terminal it says my default is python 2.7.
on running
which pip
I got /usr/local/bin/pip
Which meant it was pointing to pip2
To change default pip to pip3, run
sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip
install pip for Python2.7 with easy_install:
sudo easy_install-2.7 pip
now you can use pip for the same specific version of Python:
sudo pip2.7 install BeautifulSoup

Pip installation bug

So I tried to install pip using the get-pip.py file, and when I ran the file, terminal told me I already had pip installed on 2.7. However, when I try to find the version of my pip, terminal tells me pip doesn't exist and points to a version of 3.5 I have installed. Clearly my issue is that I have pip installed on v2.7 but the pip command is linked to v3.5. Any clues on how to fix?
Here's a picture of my terminal output:
To install a package in a particular version of python, use the following commands always:
For python 2.x:
sudo python -m pip install [package]
For python 3.x:
sudo python3 -m pip install [package]
This should resolve the doubt of which python version is the given package getting installed for.
Note: This is assuming you have not created aliases for the python command

Installing pip in different versions of python

I have multiple versions of Python installed(2.5,2.7). I am using Ubuntu. Python2.7 is my default Python interpreter. So all packages like PIL is installed in python2.7. Now i want to install some packages in Python 2.5 version.
I need to install Pip so that i could install the packages. Now i do understand some would give the advice of virtualenv. I tried that too.
But installing Pil through that too doesn't show the packages in the python2.5 version. It installs it in python2.7 version. So i need to do something so that when pip installs the package it installs it in Python2.5 version. Any suggestions?
I also tried this:
python2 -m pip install SomePackage # default Python 2
python2.5 -m pip install SomePackage # specifically Python 2.5
but it says no module named pip
According to this answer: pip: dealing with multiple Python versions?
You have to try like this if pip >= 1.5:
$ pip2.5 install SomePackage
$ pip2.7 install SomePackage
Else:
$ pip-2.5 install SomePackage
$ pip-2.7 install SomePackage