简体   繁体   中英

Why python .exe doesn't run on some PCs and others it does (Using pyinstaller)

I'm working with selenium for automated tests, and I already did some upgrade to this script, like:

Setting up chromedriver.exe with --add-binary to .exe file, so once it starts executable creates temporary folder with chromedriver.

path = os.getenv('username')


def resource_path(relative_path):
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.dirname(__file__)
    return os.path.join(base_path, relative_path)


options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\{}\\AppData\\Local\\Google\\Chrome\\User Data".format(path)) #Path to your chrome profile
driver = webdriver.Chrome(resource_path(".\\driver\\chromedriver.exe"),options=options)

Then I realized that my .exe was been detected as a virus, found an solution for it, setting up bootloader for Pyinstaller.

And now I don't know why this .exe on some PCs it works with no problem, and in others it does nothing, no error is showed, also running it with terminal.

Important

When I compile and build the same script on the PC that my .exe doesn't run, the .exe built on that PC works perfectly.

Both OS are Windows 10 64bit; The bootloader is set to win10 32bit and working on win10 64bit.

Python 3.9.0

When I compile and build the same script on the PC that my .exe doesn't run, the .exe built on that PC works perfectly.

That should tell you something is different between your two environments. It's a little strange you don't get any kind of error output.

From the pyInstaller docs :

The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:

  • a different OS

  • a different version of Python

  • a 32-bit or 64-bit OS

you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size.

So check the OS matches (especially 32-bit vs. 64-bit), and also the python version(??)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM