Python & Pip¶
To make sure python and pip are installed:
python --version
pip --version
On *nix python
usually reference python2. For python3:
python3 --version
pip3 --version
Windows install¶
Download and install python manually or use chocolately:
choco install python
In Windows 10 python 3.9 could be installed from Windows Store: just type 'python' in console and windows will open Windows Store's python page. No additional actions required after installation.
Note that windows store python will require minium virtualenv 20.0.11 (or above). (if virtualenv not yet installed then no worry - plugin will install the correct version)
Linux/Macos install¶
On most *nix distributions python is already installed, but often without pip.
Install pip if required (ubuntu example):
sudo apt-get install python3-pip
Make sure the latest pip installed (required to overcome some older pip problems):
pip3 install -U pip
To install exact pip version:
pip3 install -U pip==20.0.11
Note that on ubuntu pip installed with python3-pip
package is 9.0.1, but it did not(!) downgrade
module versions (e.g. pip install click 6.6
when click 6.7 is installed will do nothing).
Maybe there are other differences, so it's highly recommended to upgrade pip with pip3 install -U pip
.
If you need to switch python versions often, you can use pyenv: see this article for ubuntu installation guide. But pay attention to PATH: plugin may not "see" pyenv due to different PATH (when not launched from shell).
Possible pip issue warning (linux/macos)¶
If pip3 list -o
fails with: TypeError: '>' not supported between instances of 'Version' and 'Version'
Then simply update installed pip version: python3 -m pip install --upgrade pip
This is a known issue related to incorrectly patched pip packages in some distributions.
Automatic pip upgrade¶
As described above, there are different ways of pip installation in linux and, more important, admin permissions are required to upgrade global pip. So it is impossible to upgrade pip from the plugin (in all cases).
But, it is possible inside virtualenv or user (--user) scope. Note that plugin creates virtualenv by default (per project independent python environment).
So, in order to use newer pip simply put it as first dependency:
python {
pip 'pip:10.0.1'
pip 'some_module:1.0'
}
Here project virtualenv will be created with global pip and newer pip version installed inside environment. Packages installation is sequential, so all other packages will be installed with newer pip (each installation is independent pip command).
The same will work for user scope: python.scope = USER
When applying this trick, consider minimal pip version declared in configuration
(python.minPipVersion='9'
by default) as minimal pip version required for project setup
(instead of minimal version required for work).
Automatic python install¶
Python is assumed to be used as java: install and forget. It perfectly fits user use case: install python once and plugin will replace all manual work on project environment setup.
It is also easy to configure python on CI (like travis).
If you want automatic python installation, try looking on JetBrain's python-envs plugin. But be careful because it has some caveats (for example, on windows python could be installed automatically just once and requires manual un-installation).