I'm new to python. I use Visual Studio Code.
My current understanding is as follows:
For each project, I create a virtual environment. Now if I want to have some linter while coding, I need to install it with "pip install pylint" for example. IF I want to ship my code to users now then I should create a requirements.txt. However, after installing pylint, it looks like this:
astroid==2.3.3
colorama==0.4.3
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pylint==2.4.4
six==1.13.0
wrapt==1.11.2
All these packages are actually not necessary for my code, they all come from pylint.
A requirements.txt file in Python lets you keep track of the modules and packages used in your projects. Simply put, a requirements.txt file is simply a .txt file that tracks all of your requirements. This makes it easier to install the required packages, whether for yourself or for other users of your code.
Having @ file:///* after the package name instead of the package version is not good formatting for the requirements.txt file. It is an open issue identified in versions of pip such as 20.1 and 21.0.1. Again, the output requirements.txt file may have some extra packages, and you can always go into the file and manually remove them.
Sometimes the dependency is listed above the package it depend upon. The solution is simple: 1.pip install package_name 2.simply put the error package to the bottom of the requirements.txt 3.sometimes a particular version of the package is not be able to be installed,just install the newest version of it and update the data in requirements.txt
You can always open your requirements.txt file and manually remove any extra packages. The code below shows a sample requirements.txt file gotten through pip freeze > requirements.txt One thing many people have noticed with some pip packages is that they put @ file:///* after some package name — were * as a wildcard character.
You should create a requirements.txt
file that has exactly what you need to run the project and a dev-requirements.txt
file that includes requirements.txt
and your development dependencies. The easiest way I have found to manage this is to use a tool like pip-tools or poetry.
For the former, you would have a requirements.in
which lists your execution dependencies unpinned. Then in your dev-requirements.in
you would have:
-r requirements.txt
pylint
You can then use pip-compile
to generate the requirements.txt
file and the dev-requirements.txt
files and pip-sync
to make sure your packages installed in your environment matches what is specified in the requirements file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With