Как установить pip на windows 10
Перейти к содержимому

Как установить pip на windows 10

  • автор:

 

Installing packages using pip and virtual environments¶

This guide discusses how to install packages using pip and a virtual environment manager: either venv for Python 3 or virtualenv for Python 2. These are the lowest-level tools for managing Python packages and are recommended if higher-level tools do not suit your needs.

This doc uses the term package to refer to a Distribution Package which is different from an Import Package that which is used to import modules in your Python source code.

Installing pip¶

pip is the reference Python package manager. It’s used to install and update packages. You’ll need to make sure you have the latest version of pip installed.

Debian and most other distributions include a python-pip package; if you want to use the Linux distribution-provided versions of pip, see Installing pip/setuptools/wheel with Linux Package Managers .

You can also install pip yourself to ensure you have the latest version. It’s recommended to use the system pip to bootstrap a user installation of pip:

Afterwards, you should have the latest version of pip installed in your user site:

The Python installers for Windows include pip. You can make sure that pip is up-to-date by running:

Afterwards, you should have the latest version of pip:

Installing virtualenv¶

If you are using Python 3.3 or newer, the venv module is the preferred way to create and manage virtual environments. venv is included in the Python standard library and requires no additional installation. If you are using venv, you may skip this section.

virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.

Creating a virtual environment¶

venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation. When you switch projects, you can simply create a new virtual environment and not have to worry about breaking the packages installed in the other environments. It is always recommended to use a virtual environment while developing Python applications.

To create a virtual environment, go to your project’s directory and run venv. If you are using Python 2, replace venv with virtualenv in the below commands.

The second argument is the location to create the virtual environment. Generally, you can just create this in your project and call it env .

venv will create a virtual Python installation in the env folder.

You should exclude your virtual environment directory from your version control system using .gitignore or similar.

Activating a virtual environment¶

Before you can start installing or using packages in your virtual environment you’ll need to activate it. Activating a virtual environment will put the virtual environment-specific python and pip executables into your shell’s PATH .

You can confirm you’re in the virtual environment by checking the location of your Python interpreter:

Installation#

If your Python environment does not have pip installed, there are 2 mechanisms to install pip supported directly by pip’s maintainers:

ensurepip #

Python comes with an ensurepip module1, which can install pip in a Python environment.

More details about how ensurepip works and how it can be used, is available in the standard library documentation.

get-pip.py #

This is a Python script that uses some bootstrapping logic to install pip.

Open a terminal/command prompt, cd to the folder containing the get-pip.py file and run:

More details about this script can be found in pypa/get-pip’s README.

Standalone zip application#

The zip application is currently experimental. We test that pip runs correctly in this form, but it is possible that there could be issues in some situations. We will accept bug reports in such cases, but for now the zip application should not be used in production environments.

In addition to installing pip in your environment, pip is available as a standalone zip application. This can be downloaded from https://bootstrap.pypa.io/pip/pip.pyz. There are also zip applications for specific pip versions, named pip-X.Y.Z.pyz .

The zip application can be run using any supported version of Python:

If run directly:

then the currently active Python interpreter will be used.

Alternative Methods#

Depending on how you installed Python, there might be other mechanisms available to you for installing pip such as using Linux package managers .

These mechanisms are provided by redistributors of pip, who may have modified pip to change its behaviour. This has been a frequent source of user confusion, since it causes a mismatch between documented behaviour in this documentation and how pip works after those modifications.

If you face issues when using Python and pip installed using these mechanisms, it is recommended to request for support from the relevant provider (eg: Linux distro community, cloud provider support channels, etc).

Upgrading pip #

Upgrade your pip by running:

Compatibility#

The current version of pip works on:

Windows, Linux and MacOS.

CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.

pip is tested to work on the latest patch version of the Python interpreter, for each of the minor versions listed above. Previous patch versions are supported on a best effort approach.

Other operating systems and Python versions are not supported by pip’s maintainers.

Users who are on unsupported platforms should be aware that if they hit issues, they may have to resolve them for themselves. If they received pip from a source which provides support for their platform, they should request pip support from that source.

The ensurepip module was added to the Python standard library in Python 3.4.

Name already in use

pip / docs / html / installation.md

  • Go to file T
  • Go to line L
  • Copy path
  • Copy permalink
  • Open with Desktop
  • View raw
  • Copy raw contents Copy raw contents

Copy raw contents

Copy raw contents

Usually, pip is automatically installed if you are:

  • working in a virtual environment <pypug:Creating and using Virtual Environments>
  • using Python downloaded from python.org
  • using Python that has not been modified by a redistributor to remove ensurepip

If your Python environment does not have pip installed, there are 2 mechanisms to install pip supported directly by pip’s maintainers:

 

Python comes with an ensurepip module 1 , which can install pip in a Python environment.

More details about how ensurepip works and how it can be used, is available in the standard library documentation.

This is a Python script that uses some bootstrapping logic to install pip.

Open a terminal/command prompt, cd to the folder containing the get-pip.py file and run:

More details about this script can be found in pypa/get-pip’s README.

Standalone zip application

In addition to installing pip in your environment, pip is available as a standalone zip application. This can be downloaded from https://bootstrap.pypa.io/pip/pip.pyz. There are also zip applications for specific pip versions, named pip-X.Y.Z.pyz .

The zip application can be run using any supported version of Python:

If run directly:

then the currently active Python interpreter will be used.

Depending on how you installed Python, there might be other mechanisms available to you for installing pip such as using Linux package managers <pypug:installing pip/setuptools/wheel with linux package managers> .

These mechanisms are provided by redistributors of pip, who may have modified pip to change its behaviour. This has been a frequent source of user confusion, since it causes a mismatch between documented behaviour in this documentation and how pip works after those modifications.

If you face issues when using Python and pip installed using these mechanisms, it is recommended to request for support from the relevant provider (eg: Linux distro community, cloud provider support channels, etc).

Upgrade your pip by running:

The current version of pip works on:

  • Windows, Linux and MacOS.
  • CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.

pip is tested to work on the latest patch version of the Python interpreter, for each of the minor versions listed above. Previous patch versions are supported on a best effort approach.

Other operating systems and Python versions are not supported by pip’s maintainers.

Users who are on unsupported platforms should be aware that if they hit issues, they may have to resolve them for themselves. If they received pip from a source which provides support for their platform, they should request pip support from that source.

Footnotes

The ensurepip module was added to the Python standard library in Python 3.4. ↩

What is PIP?

PIP is a recursive acronym that stands for “PIP Installs Packages” or “Preferred Installer Program”. It’s a command-line utility that allows you to install, reinstall, or uninstall PyPI packages with a simple and straightforward command: pip.

Installing Python and PIP

Installation Guide for MacOS:

1) Go to https://www.python.org/downloads/windows/ and download Python 3.6.4 (As later versions aren’t supported at the time of writing).

2) Once you’ve downloaded it, launch it and be sure to select the custom option for install. This takes you into a configuration dialog where you can choose pip as an option to install.

3) It is recommended to select them all.

4) Check if the python version is 3.6.4.

You’re now good to go with the Python runtime and pip installer for MacOS 🙂

Installation Guide for Windows 10:

1) Go to https://www.python.org/downloads/windows/ and download Python 3.6.4 (As later versions aren’t supported at the time of writing).

2) Once you’ve downloaded it, launch it and be sure to select the custom option for install. This takes you into a configuration dialog where you can choose pip as an option to install.

3) It is recommended to select all the options while installing.

4) After the installation is complete, open the terminal at type:

5) Exit the Python Interpreter.

6) Test your pip installation.

(You’re now good to go with the Python runtime and pip installer for Windows. ��)

Managing Python Packages with PIP

Once PIP is ready, you can start installing packages from PyPI:

To install a specific version of a package instead of the latest version:

To search PyPI for a particular package:

To see details about an installed package:

To list all installed packages:

Packages for machine learning!

For Machine Learning, one requires a lot of packages. You can either install one by one when you need or install everything in advance. However, it is recommended to install them all at once.

(These are the required packages for the sample program linked below. Feel free to install based on your needs.)

Installing Statsmodel: (OPTIONAL) — If the above method didn’t work.

  1. You can get the latest source from our github repository. Or if you have git installed:

2. Go to the statsmodel directory.

3. If you want to keep up to date with the source on github just periodically do:

4. Once you have obtained the source, you can do (after you open terminal as administrator):

Write your first program:

You can begin testing your packages with your first machine learning program here.

 

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *