I have a strange situation where I have a normal user account on windows where I have access to the internet and then an admin account without internet access.
Given this, how can I split the installation of easy_install and pip into two steps and get it installed on my machine?
I usually do the following:
Download get-pip.py from https://pip.pypa.io/en/stable/installing/
Run it using python get-pip.py
You're done!
Of course, with the latest version of Python, pip is included, I believe.
You can combine as follows:
pip install -d <dir-name> <package-name>
pip install -f <dir-name> --no-index <package-name>
The 1st one will download the packages locally and the 2nd one will install them. Make sure you create the directory first.
That was simple.
Figured out that pip is installed automatically with python 2.10 and upgraded it to solve the problem!
Related
I think I uninstalled pip by mistake ^^
I ran something like "pip uninstall pip" in CMD and it completely broke, giving fatal errors.
I uninstalled and reinstalled python, added the correct folders back to PATH, but now it's only working via python -m pip XXXX and not by typing pip XXXX...
If I type pip XXX i get an empty row and CMD gives me back the cursor.
How can I recover? I liked pip XXX better and I am sure that the pip folder is in PATH.
It would help greatly to know what version of each you are using and what OS but for a generic answer...
You could try to install it manually:
Vist:
https://pip.pypa.io/en/stable/installing.html
Download:
get-pip.py
python get-pip.py
Make sure your python version matches your pip version. Otherwise you will always have to be specific on your installs. And for sake of simplicity make sure it works fine with just one version of Python installed. Then if that works you can consider having more.
After installing it, if you upgrade your python version make sure you keep it up to date.
I would try something like:
pip install --upgrade --no-deps --force-reinstall
As os version 21.3.1, you can install pip with the one-liner:
python -m ensurepip --upgrade.
See installation of pip doc for details.
I want to install some packages on the server which does not access to internet. so I have to take packages and send them to the server. But I do not know how can I install them.
Download all the packages you need and send them to the server where you need to install them. It doesn't matter if they have *whl or *tar.gz extension. Then install them one by one using pip:
pip install path/to/package
or:
python -m pip install path/to/package
The second option is useful if you have multiple interpreters on the server (e.g. python2 and python3 or multiple versions of either of them). In such case replace python with the one you want to use, e.g:
python3 -m pip install path/to/package
If you have a lot of packages, you can list them in a requirement file as you would normally do when you have access to the internet. Then instead of putting the names of the packages into the file, put the paths to the packages (one path per line). When you have the file, install all packages by typing:
python -m pip install -r requirements.txt
In the requirements file you can also mix between different types of the packages (*whl and *tar.gz). The only thing to take care about is to download the correct versions of the packages you need for the platform you have (64bit packages for 64bit platform etc.).
You can find more information regarding pip install in its documentation.
You can either download the packages from the website and run python setup.py install. Or you can run a pip install on a local dir, such as :
pip install path/to/tar/ball
https://pip.pypa.io/en/stable/reference/pip_install/#usage
Download the wheel packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ . You may install the .whl packages by pip install (package.whl) , refer installing wheels using pip for more.
Download the package from website and extract the tar ball.
run python setup.py install
I'm stuck with an issue. I have a Python script that I would like to run on my OSX but seems that I crossed on many issues.
To run the script I should have both Python and Moviepy installed.
To install Moviepy I used this command:
sudo pip install moviepy
The response was:
sudo: pip: command not found
So I tried to install pip, with the command:
sudo easy_install pip
And got this answer:
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
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 to run again the
sudo pip install moviepy
but I still got that issue. What I should do?
UPDATE:
not sure on OSX, but can u try pip3 – Rehan Azher 23 mins ago
sudo pip3 install moviepy
Password:
sudo: pip3: command not found
It seems that pip is not in your path, but as long as Python can find it: sudo python -m pip install moviepy should do it. Check your $PATH env. variable, tho. – zwer 14 mins ago
sudo python -m pip install moviepy
/usr/bin/python: No module named pip
UPDATE2
A good option for you is to consider installing pip using one of OSX's
sources, like the apt program in Debian-based distributions, rather
than easy_install. – Shiva 4 hours ago
sudo apt install moviepy
Password:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/apt" (-1)
No idea why everyone keeps getting stuck on this. You have a
fundamental decision to make when using Python. You either run Python
2.7 that Apple ships and which is ancient and doesn't have pip or you use homebrew and install Python3 and pip3 and put /usr/local/bin at
the start of your PATH. But don't try a mixture of the two. – Mark
Setchell 3 hours ago
Tried to install homebrew but it cannot find the package moviepy that I am looking for.
Try with this:
pip3 install package-name
This works for me!
Yes, it's a mess. Today, your best option is to leave the ageing, OS-provided version of Python (all the stuff in /Library/Python and similar) alone and start fresh.
It looks like you've already done this (since you have an executable at /usr/bin/python) but if not, the easiest way to get Python 2 is to use Homebrew. Install Homebrew using the instructions on the website and then use it to install Python:
brew install python#2
Python 2.7.9+ comes with pip already, but if you've ended up with an older version then use python itself and get-pip.py to install pip (instead of easy_install, which is deprecated):
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
Note that get-pip.py includes a copy of pip in order to install pip effectively. Yes, things are that bad.
Finally, note that Python 2 will be end of life in less than 6 months. If you have the luxury, consider skipping straight to Python 3. Then it's as easy as:
brew install python
because pip3 comes with python3 since version 3.4. Homebrew manages to handle the installation of both Python 2 and Python 3 without conflict.
Note this procedure is different on every operating system and every month or two. But at least it should get you going for the foreseeable future.
Can you go to python shell and type import pip? If that works, then it means the pip package is installed, but there is no command-line script/program available.
In my computer, the command-line pip program is actually a python script in itself, and is located in /usr/local/bin/, which is in my PATH. Below are the contents of my pip script.
#!/usr/bin/python
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
This is a dirty trick. What you could do is to create a new file called pip in your /usr/local/bin/ directory (or similar for OSX) and copy the above lines into it.
sudo touch /usr/local/bin/pip # create a new empty file called "pip"
# ... open the file in your favorite editor, copy the above contents and save the file
sudo chmod +x /usr/local/bin/pip # make it executable
The first line in the file (#!/usr/bin/python), called "Shebang", points to the program that should execute this file when you run it on your command-line. You should put the path to the python program in your computer over there.
So I installed Mercurial with:
pip install mercurial
Now, when I am doing:
pip install -r requirements.txt
I get:
> Cannot find command 'hg'
Is there any way to make pip use c:\python27\scripts\hg.bat as the hg command? I can run it simply by typing hg, so I assumed that pip would also.
I did try using:
mklink c:\windows\system32\hg.bat c:\python27\scripts\hg.bat
And:
mklink c:\windows\system32\hg.exe c:\python27\scripts\hg.bat
Neither with any affect.
I have looked elsewhere on Google, and every answer concerning hg assumes that you've either used apt-get or the installer to get Mercurial installed.
If there is a way to use the mercurial available with pip, I'm thinking that the initial setup of any Windows development environment would go quicker.
I am using Windows 7 (32-bit Python 2.7.10).
Thanks in advance for any help.
I am using a raspberry pi 2 board with Raspian. In order to be consistent with my mac I created a separate version of Python v2.7.10. I installed a number of packages that where recommended and I was able to compile it. I placed it in /usr/local/opt/Python2.7.10. I then updated my path environment so that this directory comes first. The original Python 2.7.3 is located at /usr/bin
Now I need to get pip installed. I downloaded get-pip.py and executed it. pip was installed in /usr/local/bin, which is not where either versions of Python exists. This doesn't look right to me. I am not sure if this pip is for the original Python or for the newer version of Python that I created. I just don't want to mix the two. Is this the correct location or do I need to get it somewhere in /usr/local/opt/? I am not sure how to get pip to install in /usr/local/opt/Python2.7.10/bin.
pip: dealing with multiple Python versions?
To use pip on a specific Python, you need to make sure you have downloaded pip and installed pip for that python version:
curl -O https://bootstrap.pypa.io/get-pip.py
/path/to/python27 get-pip.py
Then use specific pip version to install packages:
pip2.7 install somePackage