Python install third-party libraries/packages (command/detailed comments), such as installing the pyinstaller library

PyInstallerThe library converts the .pysource code into an executable file
that does not require source code. The source program is compiled and packaged into a program that can be directly executed.
Linux
WindowsExe file
Mac OS X
System executable file
Official website:
http://www.pyinstaller.org/
PyInstaller belongs to a third-party library: use Additional installation is required before
-installing a third-party library requires the pip tool to install
pyinstallererthe third-party library that needs to be run, so it cannot be installed in the IDLE environment. It
needs to be installed on the comand command line under the windows platform,
such as the Linux/Mac OS X platform. Corresponding command line to execute pip instructions
to install third-party libraries through instructions

pip install pyinstaller

If the windows system only has one python installed, then
execute this one (if the network speed is fast enough)

pip install pyinstaller

If the internet speed is not enough, borrow from Qinghuayuan

pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple/

When there are several versions of python in the linux system, the
default setting command python is version 2.7 and python3 is version 3.9.
What I execute is

python3 -m pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple/

-m

-m Switch to running an appropriate copy of pip

Specify the python version to install a library/package

python -m pip install SomePackage
python3 -m pip install SomePackage

Specify the python version to install a specified version of the library/package

python -m pip install SomePackage==1.0.4    # specific version
python3 -m pip install SomePackage==1.0.4    # specific version

Specify python to install a library/package that is higher than a certain version.
When using comparator operators,
such as >, <or some other special characters interpreted by the shell, the package name and version should be enclosed in double quotes:

python -m pip install "SomePackage>=1.0.4"  # minimum version
python3 -m pip install "SomePackage>=1.0.4"  # minimum version

An upgrade version of a library / package
to run pip install --upgradethe package to upgrade to the latest version of the
multiple python versions for the input version

python -m pip install --upgrade SomePackage
python3 -m pip install --upgrade SomePackage

When you see this, it still fails to install, or there is an error, then it may be that your python does not have pip installed
. Install the pip installer.
Starting with Python 3.4, it is included in the Python binary installer by default.
When your pip is not installed by default.
The solution is:

python -m ensurepip --default-pip

Display all packages installed in the virtual environment

pip listAll packages installed in the virtual environment will be displayed

pip list

Insert picture description here
pip show will display information about a specific package (note that this is generally used in a virtual environment and needs to be viewed in the virtual environment)

pip show SomePackage

Insert picture description here
Uninstall a library/package

pip uninstall

Such as uninstalling you-get

pip uninstall you-get

Pack the installation list into a txt file

pip freezeA similar list of installed packages will be generated
(you need to enter the virtual environment you specify and then package/execute this instruction)

pip freeze > requirements.txt

View the txt file of the packaging result

linux system

cat requirements.txt

In windows system (click to open it)

type requirements.txt

Install the library/package packaged in the txt file

(You need to enter the virtual environment you specify and then package/execute this instruction)

python -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt

Guess you like

Origin blog.csdn.net/weixin_47021806/article/details/115065479