'Python 'requirements.txt' file in package
SITUATION:
I have created a python package where I use the following libraries:
- matplotlib
- regex
- statistics
- os
- unittest
- coverage
my problem is that when I do pip freeze
, the result only returns
versions values for
- matplotlib==3.2.1
- regex==2020.11.13
- statistics==1.0.3.5
- coverage==5.3.1
I have read some sites where they say that this is because, for example, os and unittest comes already installed with Python3.X.
QUESTION:
- Should I include 'os', 'unittest' in 'requirements.txt'?
- If so, which is the version I should write?
Solution 1:[1]
You shouldn't include os
and unittest
in requirements.txt
.
As you read, I confirm that os and unittest are included in Python 3.X.
os
and unittest
version depends on your Python 3.X version.
Solution 2:[2]
The source was right, you should't include os etc in your requirements.txt
. Here is a little different problem with pip freeze
tho - when you are not using different environments and have all the libraries in one environment, your pip freeze
is gonna give you all the libraries you have inside and that is not helpful at all.
I'd recommend using pipreqs
library for getting all the necessary libraries you want to put in your requirements.txt
for your script.
pip install pipreqs
pipreqs /path/to/your_project
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Marte Valerio Falcone |
Solution 2 | Leemosh |