Created
June 11, 2023 04:59
-
-
Save hack-r/7196acddb96f6ca57e2753b756ba5ece to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Name of the original requirements file | |
original_file="requirements.txt" | |
# Backup the original requirements file | |
cp "$original_file" "${original_file}.bak" | |
# Read the packages from requirements.txt and install them using pip | |
while read -r package; do | |
echo "Installing $package" | |
pip install "$package" | |
result=$? | |
if [ $result -ne 0 ]; then | |
# Error occurred, remove the version number specification for the package | |
package_name="${package%%=*}" | |
sed -i '' "/^$package_name==/d" "$original_file" | |
echo "Error occurred while installing $package, version number removed from $original_file" | |
echo "Retrying installation without version number" | |
pip install -r "$original_file" | |
fi | |
done <"$original_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment