PIP – Download python packages for offline installation

GIT source).

Use it to select the required version of Python and then follow the steps presented in step two.

Please note that on older OS versions you must specify python3 or pip3 to call Python 3.xx

#!/bin/bash
mkdir packages

cat requirements.txt | while read line
do    
    error_output=$(pip3 download -d ./packages --platform win_amd64  --python-version 38 --implementation cp --only-binary=:all: --implementation cp "$line" 2>&1)    
    
    if [[ $error_output =~ "ERROR" ]]; then
    	echo "${line}"
    	echo "${line}" >> "error.txt"
    fi
done
python3 -m venv venv
source venv/bin/activate
pip install requests
pip install beautifulsoup4
pip install tqdm
python load_packages.py

It is quite possible that pyenv will not allow you to install older versions of the language on a weak machine, or some other problems may arise – unfortunately, I have not found a solution for these problems.

In this case, probably the only way out is to have a machine that has access to the Internet with the ability to install the maximum versions of Python on it. Then pyenv will definitely allow you to work with downgraded versions of Python.

Or develop athletics skills and run with application packages from office to office. First there ->

And then back <-

Conclusion

I don’t claim any skill – I’m not a professional developer and it took me a long time to get to this article. For several years I ran like the guy in the picture above. When I met with label-studio, I was tired. I tried to automate my work. And against the backdrop of a shortage of such information in Russian, I decided to talk about my adventures

It will be great if real professionals point out my mistakes and suggest the right path. Thank you in advance!

There is also an idea in the future to somehow try to get the list of dependencies automatically – for each package, without the necessary installation on the current machine with the Internet.

But for some reason it seems to me that this is a rather difficult task that a large number of developers have tried to cope with – as a result of which such wonderful solutions have appeared as poetry, uv and similar dependency management packages

My daughter, Masterpiece and Midjourney contributed to the pictures

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *