daijro / hrequests

🚀 Web scraping for humans
https://daijro.gitbook.io/hrequests/
MIT License
705 stars 44 forks source link

Pyinstaller support #29

Open NBAFrigge opened 12 months ago

NBAFrigge commented 12 months ago

Using hrequersts, after creating an exe from my Python script, I get this error at the exe startup: FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\frige\AppData\Local\Temp\_MEI441402\hrequests\bin\CR_VERSIONS.json'.

The script works fine.

import hrequests
session = hrequests.Session('chrome', version=103)
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0',
    'Accept': '*/*',
    'Accept-Language': 'it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3',
    'Referer': 'https://sell.wethenew.com/login',
    'content-type': 'application/json',
    'Alt-Used': 'sell.wethenew.com',
    'Connection': 'keep-alive',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'If-None-Match': 'W/17gujz3lxj828',
}

csrf = eval(session.get('https://sell.wethenew.com/api/auth/csrf', headers=headers, proxies=proxy).text)['csrfToken']

That is the command that auto-py-to-exe run: pyinstaller --noconfirm --onefile --console --hidden-import "discord_webhook" "D:/Dev/Main.py"

Can anybody help me?

I tried to put the hrequest in the hidden-import while using auto-py-to-exe but nothing happened

kairon0x00 commented 9 months ago

I face similar issue. Compiling with pyinstaller is working fine (I use hrequests without automated browsing support installed) but when executing I get this error :

  Downloading hrequests-cgo library from daijro/hrequests...
Traceback (most recent call last):
  File "test.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "hrequests\__init__.py", line 30, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "hrequests\response.py", line 13, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "hrequests\cffi.py", line 199, in <module>
  File "hrequests\cffi.py", line 154, in __init__
  File "hrequests\cffi.py", line 132, in load_library
  File "hrequests\cffi.py", line 39, in __init__
  File "hrequests\cffi.py", line 67, in check_library
  File "hrequests\cffi.py", line 101, in download_library
  File "hrequests\cffi.py", line 106, in download_file
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User1\\AppData\\Local\\Temp\\_MEI68602\\hrequests\\bin\\hrequests-cgo-2.1-windows-4.0-amd64.dll'
[14612] Failed to execute script 'test' due to unhandled exception!