nhorvath / Pyrebase4

A simple python wrapper for the Firebase API. ⛺
254 stars 63 forks source link

pyrebase Error after pyinstaller to exe ImportError: attempted relative import with no known parent package #10

Closed manziEric closed 4 years ago

manziEric commented 4 years ago

I dont understand why pyrebase4 will not work after making exe with pyinstaller i give the path to the module but it give strange error i have been looking for 4 day's for solution but i dont seem to finde it.

i'm on windows 10 virtual machine 64bit

Is there sombody ho can help me to figure this out?

Thanks.

import schedule import time import os import runpy

try: import pyrebase except ImportError: import pyrebase

config = {

}

def do_somthing():

dir_name = 'download/'
if os.path.exists(dir_name) and os.path.isdir(dir_name):
    if not os.listdir(dir_name):
        print("Directory is empty")
        firebase = pyrebase.initialize_app(config)
        storage = firebase.storage()

        path_in_firebase = "test.py"
        path_local = r"C:\Users\win10\PycharmProjects\winlog\download\File.py"
        storage.child(path_in_firebase).download('',path_local)
        print('Downloading...')
        time.sleep(2)
        print('Complete')
    else:

        print('Downloading completed')

        schedule.every(5).seconds.do(moveUpdate)

        while 1:
            schedule.run_pending()
            time.sleep(1)

else:
    print("Given Directory don't exists")
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)

def moveUpdate(): runpy.run_path(path_name='moveUpdate.py') print('is running...')

do_somthing()

def compare_file(): print('program running...')

schedule.every(5).seconds.do(compare_file)

while 1: schedule.run_pending() time.sleep(1)

schedule.every().day.at('18:00').do(subprocess.call("python3 main.py", shell=True))

My .spec file

-- mode: python ; coding: utf-8 --

block_cipher = None

a = Analysis(['update.py'], pathex=['C:\Users\win10\PycharmProjects\winlog', 'C:\Users\win10\PycharmProjects\winlog\venv\Lib\site-packages\schedule','C:\Users\win10\PycharmProjects\winlog\venv\Lib\site-packages\pyrebase'], binaries=[], datas=[], hiddenimports=['schedule','pyrebase'], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='update', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=True )

My error after running exe

Traceback (most recent call last): File "update.py", line 7, in File "c:\users\win10\pycharmprojects\log\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module exec(bytecode, module.dict) File "venv\Lib\site-packages\pyrebase\pyrebase.py", line 14, in ImportError: attempted relative import with no known parent package

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "update.py", line 9, in File "c:\users\win10\pycharmprojects\log\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module exec(bytecode, module.dict) File "venv\Lib\site-packages\pyrebase\pyrebase.py", line 14, in ImportError: attempted relative import with no known parent package [2112] Failed to execute script update

Make sure these boxes are checked before submitting your issue: [x] Check that your version of Python is 3.4+ [x] Check that you are on the newest version of Pyrebase [x] Check that Email/password provider is enabled in your Firebase dashboard under Auth -> Sign In Method.