Ошибка error loading python dll

I compiled my .py file running following commands:

pyinstaller myfile.py --onefile.

When i run it on my pc(Windows 10) everything works just fine.

When i try to run it on my `virtual machine(Windows 8).

I get the following error:

Error loading Python DLL
‘C:UsersMyUsernameAppdataLocalTempNUMBERSpython36.dll’
LoadLibrary: PyInstaller: FormatMessageW failed.

I already googled the error and i found many solutions but none of them worked..

//UPDATE:
If i compile it with my virtual machine, everything runs fine on the virtual machine, main pc and even on my windows server.. strange.. so it must be a problem with my main pc.

Kind Regards

asked Jan 16, 2019 at 10:03

OperationJynx's user avatar

OperationJynxOperationJynx

1112 gold badges2 silver badges7 bronze badges

I had a similar problem trying to run a python-based program (aws cli) and getting the «Error loading Python DLL … LoadLibrary: The specified module could not be found.» on Windows Server 2008 R2.

I solved this issue by installing the Visual C++ Redistributable for Visual Studio 2015 run-time components. https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145

Hope it helps!

answered Mar 5, 2020 at 16:45

José Gil Ramírez's user avatar

José Gil RamírezJosé Gil Ramírez

2,4911 gold badge13 silver badges7 bronze badges

You can use auto-py-to-exe instead:

python -m pip install auto-py-to-exe

And then wait for it to download and then write in then cmd (or terminal):

auto-py-to-exe

A screen will appear:

enter image description here

And just make as I made in the screenshot, then press «convert .py to .exe» and then press «show output folder».

Jack Deeth's user avatar

Jack Deeth

3,0523 gold badges24 silver badges38 bronze badges

answered Apr 18, 2021 at 17:13

Ali Saad's user avatar

1

This also happens when you read the .exe file located in build.

You need to run the exe located in dist folder.

If the error persists even on dist folder .exe , check the exact version of python, download python dll from internet for that exact version, in keep in the folder suggested by the error message (path where this dll is missing).

answered Apr 26, 2022 at 15:38

Shrashti's user avatar

Try to download a 32 bit version of python36.dll (or 64 if you tried 32)

That fixed the problem for me

answered Dec 4, 2022 at 16:53

Matan Dobrushin's user avatar

Fix Python DLL error by using administrative privileges

by Tashreef Shareef

Tashreef Shareef is a software developer turned tech writer. He discovered his interest in technology after reading a tech magazine accidentally. Now he writes about everything tech from… read more


Updated on November 10, 2022

Reviewed by
Alex Serban

Alex Serban

After moving away from the corporate work-style, Alex has found rewards in a lifestyle of constant analysis, team coordination and pestering his colleagues. Holding an MCSA Windows Server… read more

  • If you’re getting an Error loading Python DLL, make sure you’re using the right directory.
  • Lack of administrative privileges can often cause this problem to appear.

XINSTALL BY CLICKING THE DOWNLOAD FILE

For fixing DLL errors, we recommend Fortect:
This tool will replace the damaged or corrupted DLLs with their functional equivalents using its dedicated repository where it has the official versions of the DLL files.

  1. Download and Install Fortect on your PC
  2. Launch the tool and Start scanning to find DLL files that could be causing PC problems
  3. Right-click on Start Repair to replace broken DLLs with working versions
  • Fortect has been downloaded by 0 readers this month.

Python is a great programming language, but error loading Python DLL on their PC. This problem can lead to other issues, such as Python runtime error for example.

If you are also troubled by this error, here are a couple of troubleshooting tips to help you resolve this issue once and for all.

Why does the error loading Python DLL appear?

There are multiple reasons for this issue, but the following are the most common ones:

  • User error – Sometimes not running the proper file or not having your script configured properly can lead to DLL errors. This can also lead to PIP not recognized and other errors.
  • Lack of administrative privileges – If you don’t use administrative rights while running Python commands, sometimes you might encounter this error. You can do that by using administrator account.
  • Version incompatibility – Older versions of Python aren’t always compatible with scripts made using the latest version, which results in this error.

How can I fix the error loading Python DLL?

Before we start fixing this problem, there are a couple of quick checks that you need to perform:

  • Use the correct directory – Many users reported this issue because they used build instead of dist directory. Not using correct directory can lead to The specified module could not be found and other problems. To avoid this issue, always use dist/main
  • Check your Python version – If you compiled your script with a newer version, older versions of Python might not be able to run it. This is especially true for Windows 7 since it doesn’t support Python 3.9 or never.
  • Start the console as administrator – Before you run your script, that the command line as administrator and check if that helps.

1. Add your configuration to the Python script

  1. Open your Python file.
  2. Copy the configuration parameters to the top of the file.
  3. Save changes.

Many users reported that moving the configuration parameters from a separate file or the spec file, fixed the problem for them, so be sure to try it.

This solution can help you if you’re getting error loading python dll python310.dll or python39.dll anaconda message, so be sure to try it.

2. Use different parameters with pyinstaller

  1. Start your console.
  2. Now enter the following command: pyinstaller --upx-exclude"vcruntime140.dll" myscript.py
  3. Press Enter to run it.

Users also reported that the following commands worked for them, so feel free to try them as well: pyinstaller --onefile file_name.py
pyinstaller --noupx file_name.py

This is a simple and easy solution if you’re getting error loading python DLL in pyinstaller.

3. Add Temp directory to the list of exclusions

  1. Press Windows key + S and enter windows security. Select Windows Security from the list.
  2. Go to Virus & threat protection. Next click on Manage settings.
  3. Click on Add or remove exclusions.
    Add or remove exclusions - asus rog gaming center not working
  4. Click on Add an exclusion and select Folder.
  5. Select the following directory: C:Usersyour_usernameAppDataLocalTemp

Error loading python dll loadlibrary pyinstaller: formatmessagew failed can cause a lot of problems, but this solution might help you fix them.

Read more about this topic

  • How to open PY files on a Windows 10/11 PC
  • Windows can’t find Python executable error [QUICK FIX]
  • What is davclnt.dll & Should You Delete it?
  • Ole32.dll not Found: How to Fix or Download it Again
  • Ftd2xx.dll not Found: How to Fix or Download it Again
  • Shdocvw.dll Missing: How to Fix it or Download it Again

4. Delete files from pyinstaller folder

  1. Press Windows key + R and enter %appdata%. Press Enter.
  2. Navigate to pyinstaller directory.
  3. Delete all files from it.

This is a simple workaround and it can be helpful if you’re getting error loading Python DLL in Ultimaker Cura or AWS CLI.

The Error loading Python DLL can be problematic, but we hope you managed to solve it. If you believe that this issue is caused by a lack of permissions, our Python permission denied error guide should be able to help you.

Did you find a different solution for this problem? Let us know in the comments section below.

newsletter icon

I compiled my .py file running following commands:

pyinstaller myfile.py --onefile.

When i run it on my pc(Windows 10) everything works just fine.

When i try to run it on my `virtual machine(Windows 8).

I get the following error:

Error loading Python DLL
‘C:UsersMyUsernameAppdataLocalTempNUMBERSpython36.dll’
LoadLibrary: PyInstaller: FormatMessageW failed.

I already googled the error and i found many solutions but none of them worked..

//UPDATE:
If i compile it with my virtual machine, everything runs fine on the virtual machine, main pc and even on my windows server.. strange.. so it must be a problem with my main pc.

Kind Regards

asked Jan 16, 2019 at 10:03

OperationJynx's user avatar

OperationJynxOperationJynx

1112 gold badges2 silver badges7 bronze badges

I had a similar problem trying to run a python-based program (aws cli) and getting the «Error loading Python DLL … LoadLibrary: The specified module could not be found.» on Windows Server 2008 R2.

I solved this issue by installing the Visual C++ Redistributable for Visual Studio 2015 run-time components. https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145

Hope it helps!

answered Mar 5, 2020 at 16:45

José Gil Ramírez's user avatar

José Gil RamírezJosé Gil Ramírez

2,4911 gold badge13 silver badges7 bronze badges

You can use auto-py-to-exe instead:

python -m pip install auto-py-to-exe

And then wait for it to download and then write in then cmd (or terminal):

auto-py-to-exe

A screen will appear:

enter image description here

And just make as I made in the screenshot, then press «convert .py to .exe» and then press «show output folder».

Jack Deeth's user avatar

Jack Deeth

3,0523 gold badges24 silver badges38 bronze badges

answered Apr 18, 2021 at 17:13

Ali Saad's user avatar

1

This also happens when you read the .exe file located in build.

You need to run the exe located in dist folder.

If the error persists even on dist folder .exe , check the exact version of python, download python dll from internet for that exact version, in keep in the folder suggested by the error message (path where this dll is missing).

answered Apr 26, 2022 at 15:38

Shrashti's user avatar

Try to download a 32 bit version of python36.dll (or 64 if you tried 32)

That fixed the problem for me

answered Dec 4, 2022 at 16:53

Matan Dobrushin's user avatar

The Error Loading Python DLL error typically occurs when the user tries to open the desktop version of Google Drive or several seconds after starting the syncing procedure. In most cases, the error window points towards a Dynamic Link Library (DLL) named python27.dll.

Error Loading Python DLL

What’s causing the Error Loading Python DLL error and how to resolve it?

  • Permission issue – As it turns out, it’s possible that the reason causing this particular error message is a permission issue that is preventing the syncing feature of the Backup and Sync application to communicate properly with the Drive servers. If this scenario is applicable, you should be able to fix the issue by modifying the permissions of the Temp folder in a way to ensure that every file present there can be used by the user account that you’re actively using.
  • Backup and Sync version is incompatible with Windows version – Another potential cause that might lead to this scenario is a scenario in which the GoogleDriveSync.exe executable is not actually compatible with the Windows version. This might occur if you’re using an outdated Backup and Sync application. In this case, you can solve the problem by forcing the GoogleDriveSync.exe executable to run in Compatibility mode.
  • Executable is missing admin access – This particular error (as well as general application instability) can also be facilitated due to the fact that the main executable doesn’t have admin access. This will prevent the Google syncing app from maintaining a persistent connection with Google Drive. To fix it, simply modify the Properties of the main executable so that it runs with admin access at every startup.
  • Temp folder contains corrupted drive files – As it turns out, this interruptions during the process of syncing the local data with the Google Drive cloud might cause persistent corrupted files that will essentially break the applications. Several affected users have managed to fix the issue by cleaning the entire content of the temp folder and restarting their computer.
  • Visual C++ 2008 Redist Pack is missing – In several documented cases, this issue appeared due to the fact that an essential Visual C++ pack (2008 SP1 Redist) was missing from your Windows installation. To fix the issue in this case, all you have to do is install the missing redistributable package.
  • Outdated Backup and Sync version – Another potential cause that might be responsible for this particular issue is a severely outdated version of the Backup and Sync application. One potential fix is to uninstall the current version and install the latest version from the official download page.

1. Fix Permissions

As it turns out, one of the most common reasons that will trigger the Error Loading Python DLL error with the desktop version of Google Drive is a permission issue that ends up preventing the application from using certain files stored inside the temp folder.

Several affected users that found themselves in a similar situation have reported that they finally managed to fix the problem after they modified the default permissions of the Temp folder in a way that will include inheritable permissions from the object’s parent.

Here’s a quick guide on how to do this on Windows 7, Windows 8.1 and Windows 10:

  1. Open Windows Explorer and paste the following address in the navigation bar and hit Enter to get there instantly:
    %UserProfile%AppDataLocal
  2. Once you are inside the Local folder, scroll down through the list of folders and locate the Temp folder.
  3. After you manage to locate the correct folder, right-click on it and click on Properties from the context menu.
    Accessing the Properties settings of the Temp folder
  4. Once you’re inside the Properties screen, click on the Security tab from the ribbon bar at the top.
  5. Inside the Security tab, click on the Advanced the button associated with special permissions.
    Modifying the permissions of the temp folder
  6. Inside the Advanced Security Settings for Temp, select each entry under Permission entries and click Remove to clear the entire Permission box.
    Removing each permission entry
  7.  Once every permission entry has been deleted, check the box associated with Replace all child object permission entries with inheritable permission entries from this object. Next, click Apply to save the changes.
  8. Restart your computer and see if the problem was resolved after the next startup sequence is complete.

In case you’re still seeing the Error Loading Python DLL error even after doing these modifications, move down to the next potential fix below.

2. Run GoogleDriveSync.exe in Compatibility Mode

If you’re only encountering the Error Loading Python DLL error, the moment your Google Drive installation attempts to sync your files, chances are you will be able to fix the problem by forcing the executable to run in compatibility mode with Windows 7.

Most affected users are suggesting that this species occurs with Windows 10 insider builds or builds that aren’t updated with the latest security updates. In any case, the desktop version of Google Drive doesn’t receive the support that it deserves due to the relatively small user base.

Here’s a quick guide on forcing the GoogleDriveSync.exe to run in Compatibility Mode in order to fix the Error Loading Python DLL error:

  1. Open File Explorer and navigate to the following location to reveal the GoogleDriveSync executable:
    C:Program FilesGoogleDrive
  2. Once you see the executable, right-click on it and choose Properties from the context menu.
  3. Inside the GoogleDriveSync’s properties screen, select the Compatibility tab from the ribbon bar at the top.
  4. After you get to the correct location, check the box associated with Run this program in compatibility mode for and select Windows 7 from the drop-down menu.
    Forcing the GoogleDriveSync executable to run in compatibility mode
  5. Click Apply to save the changes, then run double-click the executable and see if the issue is no longer occurring.
    Note: If the operation was successful and you’re no longer encountering the issue, the change should be permanent. This executable is called at every startup, and you just added a compatibility layer to it.

In case the same Error Loading Python DLL error is still occurring even after enforcing this change, move down tot he next potential fix below.

3. Run executable with admin access

As it turns out, this issue can also be facilitated by the fact that the main Google Drive executable (GoogleDriveSync.exe) is not prevented to run with admin access. This will inevitably create issues and instability since the program requires a persistent connection with Google Drive.

Several affected users that encountered the same issue have confirmed that they managed to fix the issue after forcing the GoogleDriveSync.exe to run with administrator privileges.

Here’s a quick guide on forcing the desktop version of Google Drive to run with admin access:

  1. Open Windows File Explorer and navigate to the following location:
    C:Program FilesGoogleDrive
  2. Once you arrive at the correct location, right-click on GoogleDriveSync.exe and click on Properties from the newly appeared context menu.
    Accessing the Properties settings of the Temp folder
  3. Inside the Properties screen of GoogleDriveSync.exe, select the Compatibility tab at the top of the window. Next, move down to the Settings menu and check the box associated with Run this program as an administrator.
    Running as administrator
  4. Click Apply to save the changes, then restart the desktop version of Google Drive and see if the problem has been resolved.
    Running as administrator

If the same Error Loading Python DLL error is still occurring, move down to the next method below.

4. Clean the temp folder

This might seem like a crude solution, but we managed to find several user reports confirming that the Error Loading Python DLL error was entirely resolved after they ended up clearing the entire Temp directory.

After doing this and restarting the computer, they confirmed that Google Drive was finally allowed to start up and sync normally. This is evidence that temporary files can interfere with Google Drive’s desktop ability to run normally on Windows 10.

Here’s a quick guide clearing the temp folder on Windows 10 in order to fix the Error Loading Python DLL:

  1. Open File Explorer and paste the following location in the navigation bar and press Enter to get there instantly:
    %UserProfile%AppDataLocal
  2. After you manage to get inside the correct location, scroll down through the list of items and double-click on the Temp folder once you manage to locate it.
  3. Once you’re inside the Temp folder, press Ctrl + A to select every item, then right-click and choose Delete to get rid of every temporary file.
    Deleting the contents of the Temp folder
  4. After the Temp folder has been cleared, restart your computer and see if the issue is resolved at the next system startup by attempting to start Google Drive once again on your Windows computer.

If the same problem is persisting, move down to the next potential fix below.

5. Install Microsoft Visual C++ 2008 SP1 Redist

As it turns out, this particular issue can occur in situations where the desktop version of Google Drive is installed on a machine that doesn’t have the redist package included with Microsoft Visual C++.

As it turns out, several dependencies included with this package are absolutely essential for the application to work. The problem is, the Google Drive installer doesn’t include it and Windows 10 doesn’t have it installed by default.

If this scenario is applicable, you can fix the issue by downloading and installing the Microsoft Visual C++ 2008 SP1 Redistributable Package. Here’s a quick guide on how to do this:

  1. Visit this link (here), select your language and hit Download.
    Downloading the Redist pack
  2. On the next screen, check the box associated with the system architecture that you’re using. If you’re using a 32-bit version, download vcredist_x86.exe. If you have a 64-bit version, download vcredist_x64.exe instead.
    Downloading the correct vcredist installer
  3. Wait until the download is complete, then double-click on the installation executable and follow the on-screen prompts to complete the installation.
    Installing Microsoft Visual C++ Redistributable

    Note: If you’re prompted by the UAC (User Account Control), click Yes to grant admin access.

  4. Once the operation is complete, restart your computer and see if the issue is fixed.

If the same problem is persisting, move down to the final method below.

6. Install the latest Backup and Sync version

If none of the methods above have allowed you to fix the issue, it’s likely that you’re encountering the problem due to the fact that you’re using an outdated version of Google Drive’s Backup and Sync. As it turns out, this desktop version of Google Drive is notoriously known for its inability to update to the latest version.

Note: If you mistakenly deleted important files, here’s how to recover deleted files from Google drive.

If this scenario is applicable and you haven’t updated the application in a while, here’s a quick guide on uninstalling the current version and then installing the latest build available.

Note: Keep in mind that this operation will not make you lose any data. Your files are still safely tucked away on the cloud.

Here’s what you need to update to the latest Backup and Sync version:

  1. Press Windows key + R to open up a Run dialog box. Next, type “appwiz.cpl” and press Enter to open up the Programs and Features menu.
    Opening Programs and Features
  2. Once you’re inside the Programs and Features menu, scroll down through the list of installed applications and locate the Backup and Sync from Google application.
  3. When you see it, right-click on it and choose Uninstall from the newly appeared context menu.
    Uninstalling the old version of Backup and Sync from Google
  4. Next, click Yes at the confirmation prompt to begin the uninstallation process. Once the operation is complete, restart your computer to flush out the remaining temp files related to this application.
  5. Once the next startup sequence is complete, open your default browser and access this link (here).
    Downloading the newest version of Google Backup and Sync for Windows
  6. Once the download is complete, open the installation executable and follow the prompts to complete the installation before doing another system restart.
  7. After the next startup sequence, retry the operation that was previously causing the Error Loading Python DLL error and see if the problem is now sorted out.

Photo of Kevin Arrows

Kevin Arrows

Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.

Getting the subject error when I try to run an app packaged with the -F option. Here is the entire error when I move main.exe to ‘C:UsersJohnPycharmProjectsKivyTest:

Error loading Python DLL ‘C:UsersJohnPycharmProjectsKivyTestpython36.dll’.
LoadLibrary: The specified module could not be found.

I am using Pyinstaller version 3.4.dev0+97ce49bad
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
kivy v1.10.0

Here is the app (main.py):

from kivy.app import App
from kivy.uix.label import Label


class TestApp(App):
    def build(self):
        return Label(text='Test')

if __name__ == '__main__':
    app = TestApp()
    app.run()

Here is my main.spec:

# -*- mode: python -*-
from kivy.deps import sdl2, glew

block_cipher = None

options = [ ('v', None, 'OPTION'), ('W ignore', None, 'OPTION') ]

a = Analysis(['main.py'],
         pathex=['C:\Users\John\PycharmProjects\KivyTest'],
         binaries=[],
         datas=[],
         hiddenimports=[],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)
exe = EXE(pyz,
      a.scripts,
      options,
      exclude_binaries=True,
      name='main',
      debug=False,
      strip=False,
      upx=False,
      console=True )
coll = COLLECT(exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
           strip=False,
           upx=False,
           name='main')

The log of my Pyinstaller run (pyinstaller -F main.spec):
https://gist.github.com/DaytonaJohn/19e7274b7804f237704f46603ebaec5b

It does not appear to make any difference whether I use the ‘-F’, ‘-D’, ‘—onefile’, or ‘—onedir’ options. The output in the ‘dist’ directory is always the same and the log file is nearly identical (except for line prefix numbers). The app runs fine if I execute it from distmainmain.exe, but fails with the above error if main.exe is moved out of that directory. The python36.dll file is in that same directory. Obviously, python36.dll is not being bundled in main.exe. I have seen several reports of this problem, but none of the fixes worked for me. I encountered this problem with a much more complicated app, but it appears with this simple app also. Am I doing something wrong? Any help is appreciated.

  • Ошибка error loading plugin dll
  • Ошибка error loading plugin cleo newopcodes cleo
  • Ошибка error loading operating system как исправить
  • Ошибка error loading netc dll module
  • Ошибка error loading form