0

I'm writing a bot for IG using the Tkinter and InstaPy libraries. If you run the script with an interpreter, everything works correctly, but after compiling it in .exe using pyinstaller, the console returns this error after starting the browser:

FileNotFoundError: [WinError 3]The system cannot find the specified path: 'C:\Users\DANILG~1\AppData\Local\Temp_MEI12802\instapy\firefox_extension\manifest.json'.

(In the console, the error text is written in Russian, here is the translation)

At first, it seemed to me that this was due to escaping the "/" in the file path. But in addition, the user name changes in the path (it must be DanilGolovzin, while the path specifies DANILG~1). Well, if you still try to go to the desired directory, ignoring the escaping and mismatch of the user name, then _MEI71162 will not have the instapy folder.

console

  • The `DANILG~1` thing is a case of [8.3 filenames](https://en.wikipedia.org/wiki/8.3_filename). I have no idea why Python is still truncating it. – kettle Apr 02 '21 at 00:25

1 Answers1

1

The problem occures because of pyinstaller. When you build the script, in "browser.py"

ext_path = os.path.abspath(os.path.dirname(__file__) + sep + "firefox_extension")

we have ext_path like that. It works when you run it as a .py but when you build it, I think it runs in Temp folder and try to find it in that folder. So when it doesn't find, an error raise. I've solve with changing "browser.py" like that:

def create_firefox_extension():
    ext_path = os.path.abspath(os.path.dirname(__file__) + sep + "firefox_extension")
    # safe into assets folder
    zip_file = use_assets() + sep + "extension.xpi"
    files = ["manifest.json", "content.js", "arrive.js"]
    with zipfile.ZipFile(zip_file, "w", zipfile.ZIP_DEFLATED, False) as zipf:
        for file in files:
            try:
                zipf.write(ext_path + sep + file, file)
            except :
                new_ext_path = os.getcwd()+sep+"firefox_extension"
                zipf.write(new_ext_path + sep + file, file)

    return zip_file

firefox_extension

After making these changes, I've coppied the firefox_extension to .exe folder and it runs without any problem.

Danoram
  • 8,132
  • 12
  • 51
  • 71