./.pip to the PYTHONPATH environment variable,pip install -t .pip ,python from the project folder.requirements.txt file in the project. This file lists all the libraries on which the project depends, with version numbers. If the file is in place, installing the dependencies is simple: $ pip install -r requirements.txt $ pip install X==0.2 command will install the X version 0.2 library for all projects and will overwrite version 0.1 if it is already installed. Switching between A and B means a global reset of X each time, which is long and inconvenient.Anaconda environments and pyvenv from the standard Python library (3.3+)../.pip to PYTHONPATH ,pip with the -t .pip to install packages locally.source env/bin/activate and deactivate !./.pip is a relative path. As a result, when you run python from ~/dev/project_a , the ~/dev/project_a/.pip included in the list of library folders for this Python instance. Run python in ~/dev/project_b - it turns on ~/dev/project_b/.pip . Reception works on all popular platforms: Linux, Mac and Windows..pip , of course, can be any. Someone more like pip_components or libs . However, .pip quickly, and the dot at the beginning makes the folder hidden in Linux and Mac. $ echo 'export PYTHONPATH="./.pip:$PYTHONPATH"' >> ~/.bash_profile $ source .bash_profile so that PYTHONPATH is loaded into the active session. Depending on the platform, you may need to replace ~/.bash_profile with ~/.bashrc ..\.pip or .\.pip;(...other paths...) . You can set a variable both for the user and for the entire system.$ export PYTHONPATH=./.pip in Mac and Linux or > set PYTHONPATH=.\.pip Pip in Windows.$ PYTHONPATH=./.pip python main.pypip -t-t or --target : $ cd project_a project_a$ pip install requests==2.7.0 -t .pip project_a$ python >>> import requests >>> requests.__version__ '2.7.0' $ cd project_b project_b$ pip install requests==2.6.0 -t .pip project_b$ python >>> import requests >>> requests.__version__ '2.6.0' $ pip install -r requirements.txt -t .pip $ /path/to/python main.py 2to3 . Such packages do not have a single code base; during installation, the code is generated according to the active version of Python..pip3 and add it to the beginning of PYTHONPATH when you run the code with Python 3.easy_install , you will encounter a problem: easy_install appends the path to such packages to the beginning of sys.path , so they have priority over packages from .pip .import sys;sys.path in Python. If ./.pip are other paths in front of ./.pip , you may have to clean the system of global easy_install packages first.Source: https://habr.com/ru/post/261263/
All Articles