Локальная установка библеотек Python(Requests, urllib3)
Машина локальная, отлученная от интернет сети. Мне нужно спарсить наш локальный сайт и собрать информацию для отчета. Для реализации поставленной задачи я выбрал beautifulsoup. Для его работы вдруг потребовались библиотеки Request, для url запросов. Скачал поставил и столкнулся с проблемой.
C:\Users\ ......\PycharmProjects\pythonProject1\venv\Scripts\python.exe
C:\Users\ ......\PycharmProjects\pythonProject1\main.py
Traceback (most recent call last): File
"C:\Users\ ......\PycharmProjects\pythonProject1\main.py", line 2, in
<module>
import requests File "C:\Users\ .......\PycharmProjects\pythonProject1\venv\Lib\site-packages\requests-2.28.2-py3.11.egg\requests\__init__.py",
line 43, in <module>
import urllib3 ModuleNotFoundError: No module named 'urllib3'
Устанавливаю urllib3, ей тоже не хочется ставится локально!
(venv) PS C:\Users\ ......\PycharmProjects\pythonProject1py
.\download\urllib3-main\setup.py install
===============================
Unsupported installation method
===============================
This version of urllib3 has dropped support for Python 2.7 and no
longer supports installation with `python setup.py install`.
Please use `python -m pip install .` instead.
Process finished with exit code 1
Посоветуйте пожалуйста, как их установить и заставить работать через локальную установку!?
upd
попытка установки библиотеки urllib3 командой py -m pip install .\download\urllib3-2.0.0a3\ , если это команда предназначена для локальной установки то почему она пытается выйти в интернет и выполнить действие с сертификатами, и что она пытается с ними сделать?
(venv) PS C:\Users\ryzhonkov.ia\PycharmProjects\pythonProject> py -m pip install .\download\urllib3-2.0.0a3\
Processing c:\users\ryzhonkov.ia\pycharmprojects\pythonproject\download\urllib3-2.0.0a3
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to ge
t local issuer certificate (_ssl.c:992)'))': /simple/hatchling/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to ge
t local issuer certificate (_ssl.c:992)'))': /simple/hatchling/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to ge
t local issuer certificate (_ssl.c:992)'))': /simple/hatchling/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to ge
t local issuer certificate (_ssl.c:992)'))': /simple/hatchling/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to ge
t local issuer certificate (_ssl.c:992)'))': /simple/hatchling/
Could not fetch URL https://pypi.org/simple/hatchling/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/hatchling/ (Caused by SSLError(
SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)'))) - skipping
ERROR: Could not find a version that satisfies the requirement hatchling<2,>=1.6.0 (from versions: none)
ERROR: No matching distribution found for hatchling<2,>=1.6.0
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerif
icationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)'))) - skipping
WARNING: There was an error checking the latest version of pip.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificatio
nError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)'))) - skipping
WARNING: There was an error checking the latest version of pip.
(venv) PS C:\Users\ryzhonkov.ia\PycharmProjects\pythonProject>
Установка .whl файла командой py -m pip .\download\request-2.28.2-py3-none-any.whl опять сертификаты!
(venv) PS C:\Users\ryzhonkov.ia\PycharmProjects> py -m pip .\download\request-2.28.2-py3-none-any.whl
Processing c:\users\ryzhonkov.ia\pycharmprojects\pythonproject\download\requests-2.28.2-py3-none-any.whl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loca
l issuer certificate (_ssl.c:992)'))': /simple/charset-normalizer/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loca
l issuer certificate (_ssl.c:992)'))': /simple/charset-normalizer/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loca
l issuer certificate (_ssl.c:992)'))': /simple/charset-normalizer/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loca
l issuer certificate (_ssl.c:992)'))': /simple/charset-normalizer/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loca
l issuer certificate (_ssl.c:992)'))': /simple/charset-normalizer/
Could not fetch URL https://pypi.org/simple/charset-normalizer/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/charset-normalizer/ (Caused
by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)'))) - skipping
ERROR: Could not find a version that satisfies the requirement charset-normalizer<4,>=2 (from requests) (from versions: none)
ERROR: No matching distribution found for charset-normalizer<4,>=2
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificatio
nError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)'))) - skipping
WARNING: There was an error checking the latest version of pip.
Ответы (2 шт):
Если у Вас есть возможность залить какой-то файл на локальную машину, то Вы можете сделать следующие действия:
Зайти на сайт
pypi.orgи найти там модульurllib(Вот Вам ссылка на этот модуль на pypi: https://pypi.org/project/urllib3/2.0.0a3/#files)Перейдите в пункт "Загрузка файлов" и нажмите по гиперссылке с нужней версией с расширением
.whl(Вот Вам ссылка на этот файл: https://pypi.org/project/urllib3/2.0.0a3/#fileshttps://files.pythonhosted.org/packages/a2/e6/439fae33e93f8aa172d339928f7a7766bd3a5c6c1e1ef2f786d73ca9b52c/urllib3-2.0.0a3-py3-none-any.whl)После загрузки файла залейте его на свою локальную машину
Запустите
консоль/терминали перейдите в директорию со скачанным файлом!Введите команду
python3 -m pip3 install "ИМЯ_ФАЙЛА_С_РАСШИРЕНИЕМ"
После проделанных действий модуль должен успешно установиться на машину!
Проблемы решил 2 действиями.
Скачал библиотеки с идентичной ОС. На моей рабочей машине Виндовс, качал с виндовс.
Для скачивания библиотек с зависимостями использовал команды wheel.
pip install wheels- не обязательно, скачивает wheel, в актуальных версиях питона она встроена.pip wheel -w wheels/ requests/pip wheel -w wheels/ [имя_библиотеки]- скачивает библиотеку и зависимости c ней. создает папку wheels в папке с проектом.заходим в папку проекта, архивируем или проста копируем папку wheels, переносим на рабочий компьютер в папку с проектом для дальнейшей установки библиотек.
Устанавливаем библиотеки на рабочем компьютере при помощи команды
pip install --no-index -f wheels/ requests/pip install --no-index -f wheels/ [имя_библиотеки]
Получаем два вывода. Первое зависимость ОС и зависимость с зависимостями библиотек. Что препятствует простой установки библиотек для локальных работ.