In this tutorial, we will learn how to install the Pip package manager for Python in Windows PowerShell.
Pip is a tool that allows you to easily manage and install different Python packages.
Having pip installed on your system is essential for working with Python and its packages. To get started, follow the steps below.
Step 1: Download get-pip.py
First, you need to download the get-pip.py
script, which is used to install pip. Visit the official pip website by following this link and download get-pip.py
script by right-clicking the link and selecting “Save Link As…”. Save the file to a directory on your computer, for example, C:\Users\YourUsername\Downloads
.
Step 2: Open PowerShell as an Administrator
Next, open Windows PowerShell by pressing Windows key
and typing “PowerShell”, right-click on the result, and then select “Run as administrator”. This is necessary to grant PowerShell the required permissions to install pip.
Step 3: Change to the Downloads directory
Navigate to the directory where you downloaded the get-pip.py
script in Step 1. To do this, type the following command in PowerShell and press Enter
:
cd C:\Users\YourUsername\Downloads |
Make sure to replace “YourUsername” with your actual Windows username.
Step 4: Install pip
Run the following command to install pip using the get-pip.py
script:
Wait for the installation process to complete. Once it is done, you will see a message that says “Successfully installed pip”, along with some other information.
Step 5: Verify pip installation
To verify whether pip has been installed successfully, run the following command:
The output should show the installed pip version, along with the Python version it is associated with.
pip 21.2.3 from C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\lib\site-packages\pip (python 3.9)
Replace “YourUsername” with your actual Windows username.
Full Code
cd C:\Users\YourUsername\Downloads python get—pip.py pip —version |
Replace “YourUsername” with your actual Windows username.
Conclusion
Congratulations! You have successfully installed pip in Windows PowerShell. Now you can use pip to manage and install Python packages easily. Make sure to explore the pip documentation for more information about its features and usage. Happy coding!
If you do any Python development, you’ll probably run into an awful lot of package installation instructions that read:
To install, use pip:
pip install engineer
Now, that’s all fine and dandy, but what is pip? And what is this virtualenv thing people keep telling me I should use?
If you’re new to Python, getting up and running with pip and virtualenv can be a challenge, especially on Windows. Many guides I’ve seen out there assume either a) you’re working on Linux or UNIX or b) you already have pip/setuptools installed, or you know how to install packages and manage virtualenv. Heck, when I was learning this I didn’t even know what pip was! Having gone through this process several times now, I decided to write it all down from the beginning in the hopes that it’ll be useful to someone in the future.
Before We Start
A brief note before we start… To make sure we’re all on the same page, pip is a Python package installer. It integrates with PyPI, the Python Package Index, and lets you download and install a package from the package index without manually downloading the package, uncompressing it, running python setup.py install
etc. Pip makes installing libraries for your Python environment a breeze, and when you start developing your own packages it provides a way for you to declare dependencies so those dependent packages will get installed automatically as well.
The more Python development you do, though, the more packages you’re going to need. Wouldn’t it be nice if you could install all the packages into a ‘special’ location where they wouldn’t interfere with any other packages? This is where virtualenv comes in. It creates a virtual Python interpreter and isolates any packages installed for that interpreter from others on the system. There are lots of ways this comes in handy; I’ll leave enumerating them as an exercise for the reader, but if you think for a minute you can see why this will come in handy. And if you can’t yet, then give yourself a few weeks of Python development, then come back and look at this post again once you realize you need to use virtualenv.
Finally, there’s a wrapper utility for virtualenv aptly called virtualenvwrapper. This wrapper makes creating new virtual environments and switching between them really straightforward. Unfortunately, it relies on a UNIX shell, which is kind of a pain on Windows. Luckily there’s a PowerShell clone of the wrapper that works wonderfully and gives us Windows users the same kind of awesomeness that we’ve come to expect from PowerShell.
So with the definitions out of the way, let’s get started…
Ensure You Can Execute PowerShell Scripts
For the most part, this guide assumes you’ve actually used PowerShell a few times and know how to run scripts. If that’s not the case, though, then the very first thing you’ll want to do is enable scripts to run on your system using the Set-ExecutionPolicy
command. There’s a great article on TechNet that covers this in detail, so I won’t go into detail here. You can also skip this step for now if you want. Just read that article if you run into the following error message at any point:
...cannot be loaded because the execution of scripts is disabled on
this system. Please see "get-help about_signing" for more details.
Get Python
First things first – get Python! You can get the Python 2.7.8 (the current Python 2.x version as of this writing) 32-bit installer from https://www.python.org/downloads/windows/. There is a 64-bit version of Python as well, but I have personally found it to be more hassle than it’s worth. Some packages won’t have 64-bit versions available, and I personally haven’t found any need for the 64-bit version in any project I’ve worked on. Feel free to go with the 64-bit version if you’d like, but this guide assumes you’re using the 32-bit one.
Recent Python installers include an explicit option to add C:\Python27\
to your path. I find checking that option to be the easiest thing to do, and it’s generally what you want. It’s not selected by default, though, so watch for it and enable it if you want. If you don’t do that, and you need to do it manually later, the Using Python on Windows documentation includes more details.
Unfortunately, the installer does not add the Scripts
(i.e. C:\Python27\Scripts
) subdirectory, which is also really needed, since that’s where pip will end up being installed. So even if you check that box chances are you’ll need to edit your path anyway.
Once you’ve installed Python, open up a PowerShell window and type python
and press enter. You should see something like this:
PS C:\> python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Press Ctrl-Z
and hit return to exit the Python prompt. If you get an error when you type python
saying “The term ‘foo’ is not recognized as the name of a cmdlet, function, script file, or operable program,” then Python is not on your path. Add it first, and once your path is updated, restart PowerShell to ensure the new path is loaded and try typing python
again. You should be good to go!
Get Pip
Note: As of Python 2.7.10, pip can be automatically installed as part of the Python for Windows installer. If you do that, you can skip this step.
Note: Previous versions of this guide included a step to download and install Distribute. That is no longer needed; just get pip.
The easiest way to install pip is to download the get-pip.py script, save it locally, then run it using Python.
PS C:\> python get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
PS C:\>
There are other ways to get pip, but this is the easiest way I have found. There are more details on this at the pip website. To check if everything is working, just type pip
at the command line:
PS C:\> pip
Usage:
pip <command> [options]
If you get another “command is not recognized” error, check that C:\Python27\Scripts\
is on your path.
Install virtualenv and virtualenvwrapper-powershell
Pip should now be installed, so type the following commands to get virtualenv and the PowerShell virtualenvwrapper installed:
PS C:\> pip install virtualenv
PS C:\> pip install virtualenvwrapper-powershell
Now you need to import the wrapper module in PowerShell, so type Import-Module virtualenvwrapper
.
You will probably get one of two errors – or both. The first will be something like this:
PS C:\> Import-Module virtualenvwrapper
Get-Content : Cannot find path 'Function:\TabExpansion' because it does not exist.
Unfortunately that’s a bug in the current released version (12.7.8) of virtualenvwrapper-powershell. It doesn’t actually cause any problems in practice as far as I know. It seems to have been fixed in the project but the fix hasn’t made it into a released version yet. I don’t know why; I’m not involved with the project.
The other error you might see will say something like this:
Virtualenvwrapper: Virtual environments directory
'C:\Users\tyler/.virtualenvs' does not exist. Create it or
set $env:WORKON_HOME to an existing directory.
Well, at least you know you’re on the right track! Do exactly what the message says: create the missing directory.
You might also want to change the location to store your virtual environments. To do that, set the $env:WORKON_HOME
variable to wherever you want to store them. I generally stick with the default of ~\.virtualenvs
though. Whatever you do, remember this location; it will come in handy.
Now try to import the module again. Success! Now you have access to a bunch of virtualenv management commands directly in PowerShell. To see all of them, you can type:
PS C:\> Get-Command *virtualenv*
CommandType Name ModuleName
----------- ---- ----------
Alias cdvirtualenv -> CDIntoVirtualEnvironment virtualenvwrapper
Alias cpvirtualenv -> Copy-VirtualEnvironment virtualenvwrapper
Alias lsvirtualenv -> Get-VirtualEnvironment virtualenvwrapper
Alias mkvirtualenv -> New-VirtualEnvironment virtualenvwrapper
Alias rmvirtualenv -> Remove-VirtualEnvironment virtualenvwrapper
Alias setvirtualenvproject -> Set-VirtualEnvProject support
Function add2virtualenv virtualenvwrapper
Function CDIntoVirtualEnvironment virtualenvwrapper
Function Copy-VirtualEnvironment virtualenvwrapper
Function Get-VirtualEnvironment virtualenvwrapper
Function New-VirtualEnvironment virtualenvwrapper
Function New-VirtualEnvProject support
Function Remove-VirtualEnvironment virtualenvwrapper
Function Set-VirtualEnvironment virtualenvwrapper
Function Set-VirtualEnvProject support
Function showvirtualenv virtualenvwrapper
Function VerifyVirtualEnv support
Application virtualenv.exe
Application virtualenv-2.7.exe
Application virtualenv-clone.exe
You’ll see that there are a bunch of nice PowerShell style cmdlets, like New-VirtualEnvironment
, but there are also aliases set up mapping those cmdlets to commands you might be more familiar with, like mkvirtualenv
. Of course you also get regular PowerShell tab completion for these cmdlets and aliases.
Managing virtualenvs
Now that we have virtualenv installed, let’s make a new virtualenv:
New-VirtualEnvironment engineer
Replace engineer
with whatever you want to call your virtualenv. I usually name it after the project I plan to use that virtualenv for, but whatever you want works.
After the command completes, you should see a PowerShell prompt that looks like this:
The (engineer)
prepended to your prompt reminds you that you’re currently working within that virtualenv. If you type workon
now you should see the available virtualenvs, and if you type workon name_of_another_virtualenv
you’ll flip to that environment.
PS C:\> workon
PathInfo Name PathToScripts PathToSitePackages
-------- ---- ------------- ------------------
engineer engineer C:\Users\tyler\.virtuale... C:\Users\tyler\.virtuale...
Install Packages with pip
Now that your virtual environments are configured, you can install packages into them using pip. Open a PowerShell prompt, type workon name_of_virtualenv
and then type pip install package_name
. There are also a couple of additional pip commands that might be useful to know. If you have a project with lots of package requirements, it might have come with (or you might have written) a requirements file (often called requirements.txt
). To have pip load all of the packages in that file, type:
PS C:\> pip install -r path_to_requirements_file
Also, you might have downloaded a package’s source manually that has a setup.py
file in it. You can have pip install that for you by typing:
PS C:\> pip install -e path_to_source
The -e
option can also check out source directly from a Mercurial, Git, Subversion, or Bazaar repository and install a package from there.
Automatically Importing the virtualenvwrapper PowerShell Module
You might notice at some point – probably once you open a new PowerShell prompt – that you can no longer use the workon
and New-VirtualEnvironment
commands. Well, silly, you forgot to import the virtualenvwrapper
module! Now, you could just import it and move on with your life, but that’s going to get annoying really quickly, so you can configure your PowerShell profile so that the module is loaded every time you open up a PowerShell window. First, though, you’re going to need to find your profile. To make matters a bit more confusing, there are actually several profiles that PowerShell uses. But only one or two of them are really relevant to us. To see all the profiles available to you, type:
PS C:\> $profile | Format-List * -Force
AllUsersAllHosts : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\tyler\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\tyler\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Length : 77
Looks like there are four available profile scripts, and based on their names, they all have different scopes. In our case, we probably want the CurrentUserAllHosts
profile, since that will execute for us in every PowerShell instance. If you navigate to the location listed, there might not be a file there to edit. In that case, the following command will create a file there in the right format:
New-Item -Path $Profile.CurrentUserAllHosts -Type file -Force
Or you could just create a file in your favorite text editor and save it in that location (with the correct name, of course).
In that file, put the command you used to import the virtualenvwrapper
modules earlier
Import-Module virtualenvwrapper
It’s worth noting that this file is just a regular PowerShell script, so you can put other stuff in it too, such as aliases you like to set up, etc. Anyway, once that’s done, save the file and open a new PowerShell window. Now the workon
command and other virtualenv cmdlets should start functioning.
Configuring Your IDE
There is one final step to getting everything really ready for developing Python projects – setting up your IDE to use the appropriate virtualenv
for your project. There are several different IDEs out there or you could just rock Notepad++. I personally like PyCharm a lot though; I use it almost exclusively for Python development.
If you are using PyCharm, version 2.5+ has built-in support for virtualenv. You can create virtual environments directly in PyCharm or you can import ones you created earlier using virtualenvwrapper. Personally I prefer the latter since virtualenvwrapper doesn’t pick up the environments created by PyCharm (so they don’t show up when you use the workon
command, among another things).
Anyway, if you want to use an existing virtualenv, you’ll need to tell PyCharm about it. The PyCharm support site has details, but the key thing to know is that you need to point it to the python.exe
inside your virtualenv
’s Scripts
directory. In my case, the full path is C:\Users\tyler\.virtualenvs\engineer\Scripts\python.exe
.
After all of that’s done you should be good to go! You can pop open a PowerShell window and create/switch to virtualenvs as needed and install packages using pip. At this point you should have most of what you need to follow the installation instructions for most Python packages (except those that require C extension compilation, but that’s a topic for another post).
Вступление
Системы управления пакетами – инструменты, которые обычно создают для языков программирования. Они упрощают настройку и управление пакетами сторонних производителей. Pip – лучшая система управления пакетами в Python как для собственных модулей Pip, так и для модулей, установленных в виртуальных средах.
При вызове Pip он автоматически выполняет обход хранилища общедоступных пакетов Python (индекс пакетов Python, также известный как PyPI), загружает пакеты и устанавливает файлы установки.
В этой статье мы научимся устанавливать Pip в операционных системах Windows.
Устанавливаем Python
Проверим, установлены ли уже у нас Python и Pip. Запустим Терминал Windows из меню “Пуск” – через него мы будем использовать PowerShell. Вы также можете использовать терминал PowerShell, но Терминал Windows даст нам больше возможностей разработчика и обеспечит лёгкий доступ к другим оболочкам Linux или macOS. Как только откроется окно, введите следующую команду:
PS C:\> python --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Если вы получили такое же сообщение, значит на вашем компьютере нет Python. Вы можете загрузить последнюю версию Python с официальной страницы. Выберите версию, которую хотите загрузить (если объем вашей оперативной памяти превышает 4 ГБ, у вашего компьютер должна быть 64-битная архитектура).
После загрузки найдите папку Загрузки и дважды щелкните по загруженному файлу. Следуйте инструкциям ниже:
Теперь, когда Python загружен и установлен, давайте снова откроем терминал и напишем следующую команду:
PS C:\> python --version
Python 3.9.5
Устанавливаем Pip
В современных версиях Python (версии 3.4 и выше) Pip уже установлен. Можете проверить, введя следующую команду:
PS C:\> pip --version
pip 21.1.1 from c:\users\stackabuse\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
Если вы получили другое сообщение, значит, Pip либо не установлен, либо поврежден:
PS C:\> pip --version
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pip --version
+ ~~~
+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
В приведенном выше сообщении написано, что Pip не установлен. В этом случае вам понадобится исходный код для настройки Pip на вашем компьютере. Его можно загрузить с bootstrap.pypa.io, используя wget. Так вы загрузите исходный код в локальный файл get-pip.py:
PS C:\> wget https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py
Указанный файл содержит исходный код для установки последней версии Pip. Поскольку это файл Python, его можно вызвать таким же образом, как и все сценарии Python:
PS C:\> python get-pip.py
Collecting pip
Downloading pip-21.1.1-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 384 kB/s
Collecting wheel
Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, pip
Successfully installed pip-21.1.1 wheel-0.36.2
В сообщении написано, что на вашем компьютере установлена последняя версия Pip.
Удаляем Pip
Бывает, когда Pip может быть повреждён после обновления. Для полного удаления Pip используйте следующую команду:
PS C:\> pip uninstall pip
Found existing installation: pip 21.1.1
Uninstalling pip-21.1.1:
Would remove:
c:\users\sathy\appdata\local\programs\python\python39\lib\site-packages\pip-21.1.1.dist-info\*
c:\users\sathy\appdata\local\programs\python\python39\lib\site-packages\pip\*
c:\users\sathy\appdata\local\programs\python\python39\scripts\pip.exe
c:\users\sathy\appdata\local\programs\python\python39\scripts\pip3.9.exe
c:\users\sathy\appdata\local\programs\python\python39\scripts\pip3.exe
Proceed (y/n)? y
Successfully uninstalled pip-21.1.1
Заключение
Pip – одна из самых популярных систем управления пакетами, используемая разработчиками Python. В самых последних версиях Python для Windows он уже установлен. В случае ошибок, мы можем переустановить Pip, используя код.
Просмотры: 9 512
As a Windows DevOps, I often use Powershell and Python, Powershell is installed by Windows out of box, but this is not for Python. And for my working environment, I don’t have the administrator privileges on some servers. I will show you in this post how to rapidly deploy Python on Windows as a standard user by using Powershell with Nuget.
Update 2019-12-30 Installing Python by Scoop#
Installing Python on Windows by Scoop is the simplest way so far if you have Internet access.
To switch between different Python versions, please check this doc.
Finding Python packages#
If you cannot use Find-Package to search pacakges in Nuget repository, please check my post on Setting Up Nuget for Powershell.
We will install python
with version 3.6.5 and python2
with version 2.7.15.
> Find-Package python*
Name Version Source Summary
---- ------- ------ -------
python 3.6.5 Nuget Installs 64-bit Python for use in build scenarios.
python-embed 3.6.1.1 Nuget Installs 64-bit Python for use in build scenarios a...
python2x86 2.7.15 Nuget Installs 32-bit Python 2.7 for use in build scenarios.
python2 2.7.15 Nuget Installs 64-bit Python 2.7 for use in build scenarios.
Python35 3.5.1.1 Nuget Python 3.5 API
Python36 3.6.0 Nuget Python 3.6 API
pythonAndroid-2.7-x86_64-22... 1.0.0.7 Nuget Python 2.7 android api version: 22.0.0 architecture... pythonAndroid-2.7-armeabi-v... 1.0.0.7 Nuget Python 2.7 android api version: 22.0.0 architecture... pythonAndroid-2.7-x86_64-23... 1.0.0.7 Nuget Python 2.7 android api version: 23.0.0 architecture...
Python27Dev 2.7.13 Nuget Python 2.7 unofficial dev environment package
pythonIOS-2.7-arm64-10.3 1.0.0.7 Nuget Python 2.7 iOS api version: 10.3 architecture: arm64
PythonPlotter 0.2.15 Nuget Package to allow use of matplotlib from .NET....
Python.Runtime 2.7.9 Nuget Python 2.7.9 as a single, stand-alone executable wi...
PythonLibs4CSharp 1.0.0 Nuget A collection of Iron Python compiled libraries with...
pythonx86 3.6.5 Nuget Installs 32-bit Python for use in build scenarios.
pythonnet_py35_dotnet 2.3.0 Nuget Python 3.5 and .NET Framework
pythonnet_py27_dotnet 2.3.0 Nuget Python 2.7 and .NET Framework
Python27 2.7.6 Nuget Python 2.7 API
PythonConsoleControl 1.0.1 Nuget PythonConsole
Python3 3.6.3.2 PSGallery Python3 interpreter
PythonSelect 1.0.0 PSGallery Select a Python distribution to use within a PowerS...
PythonConverter.dll 1.0.0 Nuget Package description
Installing Python#
# To install Python 3
> Install-Package python -Scope CurrentUser
# To install Python 2
> Install-Package python2 -Scope CurrentUser
Note 2018-08-29:
Warning
Current Find-Package python* -AllVersion
gives the lastest python version is v3.7.0
, but this version doesn’t work, the last worked Nuget python version is v3.6.6
Adding Python to user path#
I will show you the way to add Python3 into the user PATH, it will be the same way for Python2. I use the user PATH because I’m not admin on the Windows server, I cannot modify the system PATH.
# Get python3 package info path
> Get-Package python | % source
C:\Users\xiang\AppData\Local\
# For Nuget packages, the executable is always under the tools folder, and the tools folder is at the same level as .nupkg file.
> ls C:\Users\xiang\AppData\Local\PackageManagement\NuGet\Packages\python.3.6.5\tools\
Directory: C:\Users\xiang\AppData\Local\PackageManagement\NuGet\Packages\python.3.6.5\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2018-06-26 00:15 DLLs
d----- 2018-06-26 00:15 include
d----- 2018-06-26 00:16 Lib
d----- 2018-06-26 00:15 libs
d----- 2018-06-26 00:49 Scripts
d----- 2018-06-26 00:15 Tools
-a---- 2018-03-28 17:10 100504 python.exe
-a---- 2018-03-28 17:10 58520 python3.dll
-a---- 2018-03-28 17:10 3610776 python36.dll
-a---- 2018-03-28 17:10 98968 pythonw.exe
-a---- 2018-03-28 17:10 88752 vcruntime140.dll
# python needs to add 2 paths to the user PATH, one is the root folder containing python.exe, another is the Sripts folder.
> $pythonRootFolder = Join-Path (Split-Path (Get-Package python | % source)) "tools"
> $pythonScriptsFolder = Join-Path $pythonRootFolder "Scripts"
> $path = [System.Environment]::GetEnvironmentVariable('path', 'user')
> $path += ";$pythonRootFolder"
> $path += ";$pythonScriptsFolder;"
> [System.Environment]::SetEnvironmentVariable('path', $path, 'user')
Reinstalling pip#
The default pip3.exe and pip2.exe have some strange behavior that just don’t work :
> pip3
Fatal error in launcher: Unable to create process using '"'
> pip2
Fatal error in launcher: Unable to create process using '"'
You can bypass the issue by using python -m pip
, but I like to use pip directly without python -m
, the trick is just reinstalling the pip:
> python -m pip uninstall pip -y
> python -m ensurepip
Normally python -m ensurepip
will install pip v9, if you want to install pip v10, just upgrade the v9:
> pip3 --version
pip 9.0.3 from c:\users\xiang\appdata\local\packagemanagement\nuget\packages\python.3.6.5\tools\lib\site-packages (python 3.6)
> python -m pip install -U pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.1
> pip3 --version
pip 10.0.1 from c:\users\xiang\appdata\local\packagemanagement\nuget\packages\python.3.6.5\tools\lib\site-packages\pip (python 3.6)
And we can find that when installing pip v10, the pip.exe is installed too, while in pip v9, we only have pip3.exe.
> ls C:\Users\xiang\AppData\Local\PackageManagement\NuGet\Packages\python.3.6.5\tools\Scripts\
Directory: C:\Users\xiang\AppData\Local\PackageManagement\NuGet\Packages\python.3.6.5\tools\Scripts
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2018-03-28 17:10 98187 easy_install-3.6.exe
-a---- 2018-06-26 00:49 102812 pip.exe
-a---- 2018-06-26 00:49 102812 pip3.6.exe
-a---- 2018-06-26 00:49 102812 pip3.exe
-a---- 2018-06-26 00:29 98224 ptipython.exe
-a---- 2018-06-26 00:29 98224 ptipython3.exe
-a---- 2018-06-26 00:29 98223 ptpython.exe
-a---- 2018-06-26 00:29 98223 ptpython3.exe
-a---- 2018-06-26 00:29 98207 pygmentize.exe
Update on 2018-07-27:
Note
The pip version has been jumped from v10 to v18
directly, because PyPA switches the software versioning to CalVer
Configuring pip for PyPI#
If you’re in enterprise environment, you may probably dont have access to the public Python packages repository https://pypi.org/, and in this case, your enterprise should have a local Artifactory which mirrors the public https://pypi.org/. So you need to add your enterprise Artifactory PyPI URL to you Python pip conf.
You can find all the pip configuration details here.
For JFrog Artifactory:
[Updated 2017-04-15] These steps might not be required in latest Python distributions which are already shipped with pip
.
I enjoy studying other people’s development environments. They give me plenty of insights into their aesthetic choices and their productivity shortcuts. But I have seen a lot of horrible environments cobbled together by flaky batch files that are one update away from blowing up, often leaving no option but to reinstall everything from scratch. Unfortunately, they have all been Windows environments.
Recently, I tried to install Python and pip on a Windows laptop. Though I have installed Python on Windows XP and Windows Servers for several years till 2010; there have been a lot of changes both in the Windows world such as Powershell and the Python world. So there is a lot of confusing information out there for the Python beginner. And then there is Python 3. Sigh!
Suffice to say I wanted to share what I learnt in a video aimed at the Python beginner or anyone struggling to install Python on Windows. The video and the high-level transcript follows:
What is covered?
- Installing Python 2 or Python 3 on Windows 7
- Installing pip from PowerShell
- Setting up a virtualenv
- Installing via pip
How to install Python / Pip on Windows 7 (or
-
Download the MSI installer from http://www.python.org/download/. Select 32 bit or 64 bit based on the System Settings which opens by pressing Win+Break
-
Run the installer. Be sure to check the option to add Python to your PATH while installing.
-
Open PowerShell as admin by right clicking on the PowerShell icon and selecting ‘Run as Admin’
-
To solve permission issues, run the following command:
Set-ExecutionPolicy Unrestricted
-
Enter the following commands in PowerShell to download the bootstrap scripts for
easy_install
andpip
:mkdir c:\envs cd c:\envs (new-object System.Net.WebClient).DownloadFile('https://bootstrap.pypa.io/ez_setup.py', 'c:\envs\distribute_setup.py') (new-object System.Net.WebClient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'c:\envs\get-pip.py') python c:\envs\distribute_setup.py python c:\envs\get-pip.py
Once these commands run successfully, you can delete the scripts
get-pip.py
anddistribute_setup.py
HTTP Issue with distribute_setup.py?
[Updated 2015-03-05] The script distribute_setup is no longer available at its old location. Thanks to Rudhra for sharing the new location.
-
Now typing
easy_install
orpip
should work. If it doesn’t it means the Scripts folder is not in your path. Run the next command in that case (Note that this command must be run only once or your PATH will get longer and longer). Make sure to replacec:\Python33\Scripts
with the correct location of your Python installation:setx PATH "%PATH%;C:\Python33\Scripts"
Close and reopen PowerShell after running this command.
-
To create a Virtual Environment, use the following commands:
cd c:\python pip install virtualenv virtualenv acme .\acme\Scripts\activate.ps1 pip install IPython ipython3
That’s it! I suppose the same steps work for Windows 8 as well. But I don’t have a machine to try it out. Do let me know if this worked for you.