Unable to install or use pipreqs to create requirements.txt file for dependencies

Viewed 365

I have a Python project that I would like to send to someone else. I am trying to create a requirements.txt file containing the required dependencies for this script so that my partner can run the script.

I tried installing pipreqs like this: pip install pipreqs. This outputs the following:

WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
Requirement already satisfied: pipreqs in c:\python310\lib\site-packages (0.4.11)
Requirement already satisfied: yarg in c:\python310\lib\site-packages (from pipreqs) (0.1.9)
Requirement already satisfied: docopt in c:\python310\lib\site-packages (from pipreqs) (0.6.2)
Requirement already satisfied: requests in c:\users\nroll97\appdata\roaming\python\python310\site-packages (from yarg->pipreqs) (2.26.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\nroll97\appdata\roaming\python\python310\site-packages (from requests->yarg->pipreqs) (1.26.8)
Requirement already satisfied: idna<4,>=2.5 in c:\users\nroll97\appdata\roaming\python\python310\site-packages (from requests->yarg->pipreqs) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\nroll97\appdata\roaming\python\python310\site-packages (from requests->yarg->pipreqs) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\nroll97\appdata\roaming\python\python310\site-packages (from requests->yarg->pipreqs) (2.0.11)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: You are using pip version 21.2.4; however, version 22.0.4 is available.
You should consider upgrading via the 'C:\Python310\python.exe -m pip install --upgrade pip' command.

I then tried to create the requirements.txt file by running the command:

pipreqs ./my_calc.py

from the folder that contains the Python script and I get the following error:

bash: pipreqs: command not found

Why can't I use pipreqs? I use pip install all the time for other libraries.

Also, I am on a Windows computer. Is there an easier way to create the requirements.txt file even if its manually?

These are the only imports:

import pandas as pd
import os
import openpyxl
import os.path
import math
from tkinter import filedialog
1 Answers

I still wasn't able to get the pipreqs to work so I just made the requirements.txt file manually by first finding out which versions of the Python modules are being used.

I found that out like this:

import pandas as pd
import os
import openpyxl
import os.path
import math
from tkinter import filedialog
# VERSIONS OF LIBRARIES AS OF DEVELOPMENT - 04/28/2022
print("Version of pd: " + str(pd.__version__)) # 1.4.2
print("Version of openpyxl: " + str(openpyxl.__version__)) # 3.0.9
print("Version of tkinter: " + str(tkinter.TkVersion)) # 8.6

And then created the requirements.txt from those values like this (but only for the imports that are not already included in the standard Python library):

pandas==1.4.2
openpyxl==3.0.9
Related