Hello everyone , I'm brother Yang .
Speaking of Python
Package management tools , The first thing you think of must be pip
、conda
And other classic tools .
But recently I found a novel Python
Package management tools ——pdm
, It is subject to PEP582
(https://www.python.org/dev/peps/pep-0582/
) as well as node
Inspired by the way of managing library files , Help us with 「 Local project library 」 Create and manage different Python
Environmental Science .
pdm
There are many ways to install , Here we use the official recommended way to install :
python -m pip install --user pipx
python -m pipx ensurepath
Then close your terminal and restart a new one , Continue to input :
pipx install pdm
When the following appears , On behalf of us pdm
The installation is complete ~
Use pdm
When creating a project with the current directory as the project warehouse , We need to according to the actual needs of the project , First switch to the corresponding Python
Under the environment of version , Re execution pdm init
To initialize the project , With 3.7
For example :
cd C:\Users\pengz\Desktop\ Current blog workbench \pdm-demo
conda activate dash-apps
pdm init
When initializing a project , Fill in each question according to your actual situation :
After the above process , You will find the created... In the current directory pyproject.toml
file , It records the current pdm
Basic parameters of the project :
Next, we can use... According to the actual needs of our project pdm add
Command to install the specified single or multiple third parties Python
library , With flask
For example ( The first line of command is used to set the domestic pypi
Mirror source ):
pdm config pypi.url https://pypi.douban.com/simple/
pdm add -v flask flask-login
After installation , We can see in the current directory __pypackages_
Catalog , The library we installed earlier is installed under it in isolation , similar node
Of node_modules
Catalog :
Also with the PEP582
The project structure advocated is consistent with :
foo
__pypackages__
3.7
lib
bottle
myscript.py
In this way, the project level environment isolation effect is realized , Without creating additional virtual environments , To be in IDE
Use in pdm
The local isolation library execution program under the project is very simple , With pycharm
For example , take pdm
Open project as pycharm
After the project , Find the position shown in the figure lib
Folder , Mark it as Sources Root
that will do , Also remember to select the interpreter as pdm init
Corresponding to the environment during initialization :
Compare with the execution results of the original environment in the terminal , It can be found that environmental isolation has been successfully realized , This is because pdm
Project __pypackages__
The package in will be in the environment itself site-packages
Previously loaded , So as to better isolate the environment of the package :
If you want to restore a file in another path or on another machine pdm
project , You just need to pyproject.toml
And pdm.lock
File copy past , Then execute... Under the corresponding directory pdm sync -v
Command is enough , Very convenient , similar npm install
coordination package.json
The function of :
About pdm
For more features, you can go to its official website https://pdm.fming.dev/
Learn more about .
-------- End --------
Reply key words , Get the corresponding data :
Data Science :VS Code in Python Configuration Guide | Financial tools Tushare | Matplotlib The most valuable 50 A chart
Book reading : How to read a book | Buffett's way | value | principle | The most important thing about investing | Davis Dynasty | Where is the customer's yacht | Deliberate practice | Lincoln | Pyramid principle
Investment summary :2021Q4 | 2021Q3 | 2021Q2 | 2021Q1 | 2020Q4
visualization :Plotly Express
Finance and economics, :Plotly Application in the field of investment | draw K Line chart
Sorting algorithm : Summary | Bubble sort | Selection sort | Quick sort | Merge sort | Heap sort | Insertion sort | Shell Sort | Count sorting | Bucket sort | Radix sorting