简体   繁体   中英

Python 'requirements.txt' file in package

SITUATION:

I have created a python package where I use the following libraries:

  1. matplotlib
  2. regex
  3. statistics
  4. os
  5. unittest
  6. coverage

my problem is that when I do pip freeze , the result only returns versions values for

  1. matplotlib==3.2.1
  2. regex==2020.11.13
  3. statistics==1.0.3.5
  4. 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:

  1. Should I include 'os', 'unittest' in 'requirements.txt'?
  2. If so, which is the version I should write?

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.

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

SITUATION:

I have created a python package where I use the following libraries:

  1. matplotlib
  2. regex
  3. statistics
  4. os
  5. unittest
  6. coverage

my problem is that when I do pip freeze , the result only returns versions values for

  1. matplotlib==3.2.1
  2. regex==2020.11.13
  3. statistics==1.0.3.5
  4. 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:

  1. Should I include 'os', 'unittest' in 'requirements.txt'?
  2. If so, which is the version I should write?

python3 -m pip install -r requirements.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM