I made a script and it works perfectly but when I compile it with pyinstaller
pyinstaller --onefile --icon='icon.ico' dmi.py
It throws error, but if I don't compile it works
I know Github module is throwing error. This is the code which throwing error:
import PySimpleGUIQt as Sg
from github import Github
from urllib import parse
g = Github("ghp_**********************************")
img_data = (g.get_user().get_repo('python-files')).get_contents(
parse.quote('create.ico'), ref="main").content.replace('\n', '').encode()
layout = [
[Sg.Text(' ')]
]
window = Sg.Window("Add Tags", layout, icon=img_data, resizable=False, finalize=True)
while True:
event, values = window.read()
if event == Sg.WINDOW_CLOSED:
window.close()
break
The code below works even after compiling:
import base64
import PySimpleGUIQt as Sg
import requests
header = {"Authorization": "token ghp_*******************************",
"Accept": "application/vnd.github.v4.raw"}
encoded = base64.b64encode((requests.get('https://raw.githubusercontent.com/WoLvES-2x0/python-files/main/create.ico', headers=header)).content)
layout = [
[Sg.Text(' ')]
]
window = Sg.Window("Add Tags", layout, icon=encoded, resizable=False, finalize=True)
while True:
event, values = window.read()
if event == Sg.WINDOW_CLOSED:
window.close()
break
although I can do this in other way but main issue I'll face without this is
Get file name of all files in a repo
g_f_name = [str(i).replace('ContentFile(path="', '').replace('")', '') for i in (g.get_user().get_repo('node-files')).get_contents('') if i]
And commit changes to repo
repo.update_file(repo.get_contents('tags.txt').path, "committing files", tags_string, repo.get_contents('tags.txt').sha, branch="main")
error Is
C:\pythoncharm\pythonProject4\dist>dmi.exe
Traceback (most recent call last):
File "dmi.py", line 2, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\__init__.py", line 56, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\MainClass.py", line 59, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\Event.py", line 32, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\NamedUser.py", line 44, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\Organization.py", line 50, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\Repository.py", line 125, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "github\PublicKey.py", line 34, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "nacl\public.py", line 17, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "nacl\bindings\__init__.py", line 17, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "nacl\bindings\crypto_aead.py", line 18, in <module>
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
File "C:\Users\WoLvES\AppData\Local\Temp\embedded.rtin1sym.zip\shibokensupport\__feature__.py", line 142, in _import
ModuleNotFoundError: No module named '_cffi_backend'
[33116] Failed to execute script 'dmi' due to unhandled exception!
importing
import _cffi_backend
solves the issue, what I think is Pyinstaller somehow misses this module while compiling, and PyGithub need this module, Although in editor this grayed out but it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.