How do I install pip in python 2.7? - python

My end goal is to install the requests module, and the way to do that seems to be with pip. I have looked through the pip install documentation here http://www.pip-installer.org/en/latest/installing.html
The documentation has offered me no help. It tells me to "securely download get-pyp.py". I have been searching for a way to do this, and so far, everything I have seen recommends the command
curl --silent --show-error --retry 5 https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python2.7
I have been unable to figure out how to use this command. Curl is not a python command. I installed curl for windows and ran this command in windows command line, which worked, but I was unable to proceed from there. Is this intended to be installed with windows command line, or something else? I am lost.

You can first install easy_install (which is part of set up tools) from the following location
https://pypi.python.org/pypi/setuptools#windows
Right click on the link and save the file ez_setup.py and then run it.
Once that is complete and you have added the scripts to your path variable (C...Python2.7..scripts), you can install pip using
easy_install pip
Check out this video for more help.
http://www.youtube.com/watch?v=MIHYflJwyLk&feature=youtu.be

Download the correct version from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip
And can find more info in this question: How do I install pip on Windows?

Related

How do I use pip install?

When I look up tutorials on Python almost every one starts with "Start of with pip install bs4" but they never tell me about how. Because when I write "pip install bs4" in my cmd the answer I get is only
'pip' is not recognized as an internal or external command,
operable program or batch file.
I've tried running "pip install bs4" in PyCharm as well but nothing works.
I am a totally a beginner, which you probably already noticed, and just want to get beautifulsoup.
I'm going to assume you're on Windows since your error message contains "batch file". Try:
py -m pip install bs4
The -m flag will import the pip module, and allow you to run the install command. If running py doesn't work, try the absolute path to your python.exe.
This is the official site that shows you how to download and install python pip
pretty much just download the file, open up the command prompt, cd to file directory and run it with:
python get-pip.py

Installing PIP on Windows 10 python 3.5

I just started learning Python, and successfully downloaded Python 3.5. I attempted to download/upgrade PIP 8.1.2 multiple times using get-pip.py, which I ran (successfully I think) but when I attempted to execute python get-pip.py
I got the error code:
File "<stdin>", line 1
python get-pip.py
^
SyntaxError: invalid syntax
I understand that pip is included in python but the pip website requires users to upgrade pip which I don't think I can since any pip commands lead to syntax errors, and do not produce the same output that most tutorial sites show. I have tried to find different ways to fix it, but I can't figure out whats wrong aside from pip not being on the computer in the first place or corrupted. Thank you for your assistance.
You won't need to upgrade pip if you just downloaded python 3.5, go to where you have your Python3.5 file and open the folder Scripts, you will find pip.exe. Open powershell and use the cd command to move to the folder containing pip.exe. From here you can use pip install to get modules.
Open Windows Powershell
PS C:Users\you> cd C:\path\to\scripts\folder\containing\pip
PS C:\path\to\scripts\folder\containing\pip> pip install module
Not sure what you are asking. If you want to run python get-pip.py do it in a windows command prompt, not in the python interpreter. But I do not know why you would want to do that.
You already have pip; there is no need to run get-pip. Upgrading can be done by pip itself.
But the reason you are getting errors is that all these commands, including pip itself, should be run at the command line, not in the Python interpreter.

beginner installing nosetests package

I'm trying to install the following as per the learnpythonthehardway tutorial:
pip from http://pypi.python.org/pypi/pip
distribute from http://pypi.python.org/pypi/distribute
nose from http://pypi.python.org/pypi/nose/
virtualenv from http://pypi.python.org/pypi/virtualenv
I've visited these links and clicked the download button; each file is in my downloads folder now, and I unarchive/unzipped them- not sure what this means but it seemed required. Are they "installed"? If not, what does it mean to really install them? I've tried typing nosetests in the terminal (as the book says you should), as well as tried easy_install but that doesn't seem to work. It appears my understanding is limited in a number of ways here.
I get the following -bash: nosetests: command not found, but am trying to get:
nosetests . ---------------------------------------------------------------------- Ran 1 test in 0.007s
OK
This works on mac, it may work on linux
1)Open terminal (Be prepared to enter your password)
2)Type: sudo easy_install pip
3)Type: sudo pip install distribute
4)Type: sudo pip install nose
5)Type: sudo pip install virtualenv
Hope that helps, cheers!
They are not yet installed.
Each has its own vagaries about how exactly the install process works and in fact some of those packages will include the other packages with them. I.e.
"If you use virtualenv, a copy of pip will be automatically be
installed in each virtual environment you create."
http://pypi.python.org/pypi/pip
As a relatively new python user myself, (and having gone thru a similar process not long ago) I am eagerly awaiting the more complete answers that come back for this one.
Find out where the nosetests script is. On OSX:
/usr/local/share/nosetests
Execute directly, or set up a bash alias, perhaps in .bash_profile:
alias nosetests='/usr/local/share/python/nosetests'
alias nosetests3='/usr/local/share/python3/nosetests'
You were on the right track, but the package is actually called "nose". The documentation for nose (nosetests is the script) can be found here:
https://nose.readthedocs.org/en/latest/
The short answer is that you have 2 basic options: easy_install or pip. Install using setuptools/distribute: easy_install nose. Install using pip: pip install nose
Install Python 2.7 and after just do this (only on Windows - Windows PowerShell):
Setup PATH env:
C:\Python27\;C:\Python27\Scripts\", "User"
pip is already installed
3.
.\pip install distribute
4.
.\pip install nose
5.
.\pip install virtualenv

pip on Windows giving the error - Unknown or unsupported command 'install'

I installed pip on Windows by downloading http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49 and running python setup.py install
Installation went fine with no errors.
But when I tried installing selenium package with it, it gives me the following error -
pip install -U selenium
Unknown option: u
Unknown or unsupported command 'install'
Where I'm making the mistake?
Do you happen to have the Perl pip lying around somewhere?
Sounds like the problem described here:
https://github.com/mike-perdide/gitbuster/issues/62
To check, in Windows command prompt execute:
C:\>where pip
This will potentially output the following:
C:\strawberry\perl\bin\pip
C:\strawberry\perl\bin\pip.bat
If so, this is your problem. Unistall Strawberry Perl or use the full path to python pip.
This error is because the system is finding pip.bat before it finds pip.exe.
You do NOT need to uninstall Strawberry Perl or type the whole path.
What I do is to simply type pip.exe (same number of keystrokes as apt-get) when I want to use the Python utility. This method seems to work find for me on Win7 with Python(x,y) 2.7x and Strawberry Perl installed.
Had the same problem under Ubuntu and did:
$ sudo apt-get remove pip
$ sudo apt-get install python-pip
I had this problem as well, and like Johannes said, it's because the perl pip is interfering with your Python pip.
To get around it, you can simply do this as well:
python -m pip install <package_name>
In addition to the very helpful nswer of Johannes:
If you don't want to uninstalll Strawberry, you can re-arrange the order of PATH entrys in your Windows system to ensure your Python\Scripts are found before the strawberry entries. If you don't want to do this manually, you can use tools like the "Rapid Environment Editor".
You should provide path in environment variable for pip.exe file
while executing install command you should use below command
pip.exe install selenium
This will surely work, for me this worked :)
You can also solve this problem without removing Strawberry Perl or type the whole path.Move to this C:\Python2.7\Scripts(your Python directory) directory,then use pip command.
For Python 3.X and above:
In the CMD prompt type:
py -m pip install <package_name>
Make sure pip is installed already.
Setup the environment variable for pip pointing to the exe file
To upgrade:
py -m pip install --upgrade pip
Same issue with DwimPerl. Uninstalling Dwim fixed the issue as well.
C:\Python27\Scripts\pip.exe install -U selenium
I have the same problem in windows 10, finally resolved the problem successfully.
I used the following command
where pip
I was showing multiple installations of pip. Once removed other installation it worked fine.
open cmd and type where pip and you will have
C:\Dwimperl\perl\bin\pip.bat
C:\Dwimperl\perl\bin
C:\Users\athus\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe
and go to C:\Dwimperl\perl and delete bin folder.
and again type where pip and you will only have
C:\Users\athus\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe
and enjoy python pip.

How to update the twisted framework

I can see from the latest 8.2 (almost 1200 lines of code) twisted that I am missing something:
http://twistedmatrix.com/trac/browser/trunk/twisted/words/protocols/jabber/xmlstream.py
My copy (697 lines from 3 years ago) is in:
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/words/protocols/jabber/xmlstream.py
I ran the mac installer found on the website, all looked like it installed fine, but obviously something I am missing:
http://twistedmatrix.com/trac/wiki/Downloads
Can someone tell me how to update twisted properly on my mac?
Try using virtualenv and pip (sudo easy_install virtualenv pip), which are great ways to avoid the dependency hell that you are experiencing.
With virtualenv you can create isolated Python environments, and then using pip you can directly install new packages into you virtualenvs.
Here is a complete example:
#create fresh virtualenv, void of old packages, and install latest Twisted
virtualenv --no-site-packages twisted_env
pip -E twisted_env install -U twisted
#now activate the virtualenv
cd twisted_env
source bin/activate
#test to see you have latest Twisted:
python -c "import twisted; print twisted.__version__"
You can download that file you mentioned by scrolling to the bottom and click "Download in other formats"
Otherwise just do svn update.
The answer was hidden away here:
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#WhyamIgettingImportErrorsforTwistedsubpackagesonOSX10.5
Not really clear on exactly how/where to fix the issue though.
After some digging I was able to solve it with this:
From the command prompt type: pico ~/.bash_profile
Add to the top of that file: export PYTHONPATH=~/Library/Python/2.5/site-packages/
Save and exit the file and you will finally be running the latest and greatest version twisted. (assuming that you have already downloaded and installed it from the twisted site)

Categories

Resources