Importerror dll load failed while importing error не найден указанный модуль

This post explains How To Fix Python Error - “ImportError: DLL load failed".We will see Generalized and more specific version of the error.


if( aicp_can_see_ads() ) {

}

This post explains How To Fix Python Error – “ImportError: DLL load failed”.

We will see Generalized and more specific version of the error.


if( aicp_can_see_ads() ) {

}

Error 
ImportError: DLL load failed:

Reasons & Fixes :

  • Sometimes it happens if there are multiple versions of Python installed. Uninstall the not reuqired version or use Python Virtual Environment (virtualenv) to separate Multiple Python versions.
  • Try reinstalling Python – You can try native Python or Anaconda Python.
  • Check if you have mixed up 64-Bit32-Bit version updates.
  • Try below –
pip install pyqt5-tools
  • This issue also happens due to Anaconda installation issue .  Check if you have set up the Anaconda path to your System Environment PATH.


if( aicp_can_see_ads() ) {

}

Fix – “ImportError: DLL load failed: The specified module could not be found.”

ImportError: DLL load failed: The specified module could not be found.

Reasons and Fix –  DLL failures are very common when Python components are installed separately or various installation channels are mixed up.

  • Add the DLL Location to the Environment PATH variable. Sometimes some update might screw up the environment variable details.
  • Run the below command if using PyQt5 .
    pip install pyqt5-tools


if( aicp_can_see_ads() ) {

}

  • Instead of installing the native Python and the packages , try out the Anaconda Python. Anaconda includes most of the major packages used in Python projects and are configured correctly. If it is related to Tensorflow set-up, Ananconda takes care of all necessary packages including the GPU and CUDA.
    conda install -c anaconda tensorflow-gpu

    It’s for Tensorflow 2.1 and Python 3.7. DLL failures are common when components are installed separately or through another channel than Anaconda.

  • Sometimes it happens if there are multiple versions of Python installed. Uninstall the not required version or use Python Virtual Environment (virtualenv) to separate Multiple Python versions.

Hope you found this post useful.

Other Interesting Reads –

  • How to log an error in Python ?

  • How to Code Custom Exception Handling in Python ?

  • How to Handle Errors and Exceptions in Python ?

  • How To Fix – “Ssl: Certificate_Verify_Failed” Error in Python ?


if( aicp_can_see_ads() ) {

}

python importerror: dll load failed: the specified module could not be found, importerror: dll load failed tensorflow, from .cv2 import * importerror: dll load failed: the specified module could not be found, importerror: dll load failed with error code -1073741795, from import _arpack importerror: dll load failed: the specified procedure could not be found, spacy dll load failed, dll load failed keras, dll load failed while importing _pywrap_tensorflow_internal, importerror: dll load failed tensorflow, dll load failed python pandas, python importerror: dll load failed: the specified module could not be found, from .cv2 import * importerror: dll load failed: the specified module could not be found, dll load failed python anaconda, importerror: dll load failed pandas, importerror: dll load failed pycharm, pop () takes no arguments 1 given python, python constructor takes no arguments, fetchall takes no arguments 1 given, typeerror popitem takes no arguments 1 given, process_iter takes no arguments (1 given), data takes no arguments, keys takes no arguments (1 given), typeerror: employee() takes no arguments, typeerror: class() takes no arguments, fetchall takes no arguments 1 given, process_iter takes no arguments (1 given), keys takes no arguments (1 given), pop() takes no arguments (1 given), layer_dense takes no arguments, data takes no arguments, typeerror: employee() takes no arguments, from .cv2 import * importerror: dll load failed: the specified module could not be found, from . import _mklinit importerror: dll load failed: the specified module could not be found, import win32file importerror: dll load failed: the specified module could not be found, importerror: dll load failed tensorflow, import _omnipy importerror: dll load failed: the specified module could not be found, from .jnius import * # noqa importerror: dll load failed: the specified module could not be found, from . import _pywraplp importerror: dll load failed: the specified module could not be found, from . import _arpack importerror: dll load failed: the specified procedure could not be found,python importerror dll load failed the specified module could not be found ,python importerror dll load failed ,python importerror dll load failed 1 is not a valid win32 application ,python importerror dll load failed the specified procedure could not be found ,python importerror dll load failed while importing ,python importerror dll load failed while importing _ssl ,python importerror dll load failed access is denied ,python importerror dll load failed while importing win32api ,python importerror dll load failed the operating system cannot run 1 ,python importerror dll load failed the network path was not found ,from .cv2 import * importerror: dll load failed: the specified module could not be found. ,importerror: dll load failed tensorflow ,from . import _mklinit importerror: dll load failed: the specified module could not be found. ,from . import ft2font importerror: dll load failed: the specified module could not be found. ,dll load failed while importing _pywrap_tensorflow_internal ,importerror: dll load failed with error code -1073741795 ,cupy dll load failed: the specified module could not be found ,importerror: dll load failed tensorflow 2 ,python dll load failed ,python dll load failed while importing ,python dll load failed access is denied ,python dll load failed not a valid win32 application ,python dll load failed while importing _multiarray_umath ,python dll load failed while importing cv2 ,python dll load failed while importing _imaging ,python dll load failed module could not be found ,python dll load failed matplotlib


if( aicp_can_see_ads() ) {

}

I’m setting up an autoclicker in Python 3.8 and I need win32api for GetAsyncKeyState but it always gives me this error:

>>> import win32api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing win32api: The specified module could not be found.

I’m on Windows 10 Home 64x. I’ve already tried

pip install pypiwin32

And it successfully installs but nothing changes. I tried uninstalling and re-installing python as well. I also tried installing ‘django’ in the same way and it actually works when I import django, so I think it’s a win32api issue only.

>>> import win32api

I expect the output to be none, but the actual output is always that error ^^

Zoe stands with Ukraine's user avatar

asked Oct 29, 2019 at 17:08

Glxce's user avatar

3

Solved

If you are working in a miniconda on conda environment. You could just install pywin32 using conda instead of pip.

This solved my problem:

conda install pywin32

iGian's user avatar

iGian

10.9k3 gold badges19 silver badges35 bronze badges

answered Oct 14, 2020 at 18:54

Janzaib M Baloch's user avatar

4

For my case, install and reinstall pywin32 doesn’t help. After copied the two files from [installation directory of Anaconda]Libsite-packagespywin32_system32 to C:WindowsSystem32, it works.

My environment is python 3.8 in miniconda. The two files are pythoncom38.dll and pywintypes38.dll.

Gjanetta's user avatar

answered Mar 10, 2020 at 3:05

Bench Wang's user avatar

Bench WangBench Wang

7621 gold badge5 silver badges3 bronze badges

9

For me, it worked by downgrading my pywin32 from version 227 to version 224. Just type the following command on any shell in administrator mode:

pip install --upgrade pywin32==224

Jaroslav Bezděk's user avatar

answered Jun 7, 2020 at 18:28

Aditya Saini's user avatar

11

Run Scriptspywin32_postinstall.py -install in an Admin command prompt

ref: https://github.com/mhammond/pywin32/issues/1431

edit: User @JoyfulPanda gave a warning:

Running this script with admin rights will also copy pythoncom37.dll, pywintypes37.dll (corresponding to the pywin32 version), into C:WINDOWSsystem32, which effectively overwrites the corresponding DLL versions from Anaconda already there. This later causes problem when openning (on Windows) «Start Menu > Anaconda3 (64-bit) > Anaconda Prompt (a_virtual_env_name)». At least Anaconda 2019.07 has pywin32 223 installed by default. Pywin32 224 may work, but 225-228 causes problem for Anaconda (2019.07)

answered Apr 9, 2020 at 20:16

José's user avatar

JoséJosé

1,6541 gold badge16 silver badges21 bronze badges

4

This happens when Libsite-packagespywin32_system32 is not in the list of directories to search for DLL (PATH environment variable).

pywin32 (or one of its dependencies) adds this path at runtime to the PATH variable. If this is failing, or another component is overriding the PATH after it’s been set by pywin32, you will get the given error (ImportError: DLL load failed while importing win32api).

You can try to extend the PATH variable in the shell before starting Python.

On Windows:

set PATH=c:...Libsite-packagespywin32_system32;%PATH%

If that doesn’t work, then the PATH maybe overridden within the Python program at runtime. Add the following line to your program just before pywin32 is used to verify its value:

import os
print(os.environ["PATH"])

As a last resort, you can extend the PATH variable before pywin32 is loaded:

Windows:

os.environ["PATH"] = r"c:...pywin32_system32;" + os.environ["PATH"]

Unix like:

os.environ["PATH"] = r"/.../pywin32_system32:" + os.environ["PATH"]

answered Jul 26, 2020 at 16:40

ocroquette's user avatar

ocroquetteocroquette

2,8991 gold badge20 silver badges25 bronze badges

4

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python pathtopythonScriptspywin32_postinstall.py -install

taken from here. worked for me!

answered Aug 17, 2020 at 15:26

Michael Tamillow's user avatar

3

For python 3.8.3, pywin32==225 worked for me, the existing pywin32==228 was uninstalled.

So try this

pip install pywin32==225

Hope it solves your problem

Jean-François Fabre's user avatar

answered Mar 27, 2021 at 18:24

suhas sasetty's user avatar

1

What helped me was

  1. installing relevant binary from github.com/mhammond/pywin32
  2. executing the following commands in the x64 command line:

cd C:ProgramDataAnaconda3Scripts

python pywin32_postinstall.py -install

answered Jun 7, 2022 at 8:10

Anatoly Alekseev's user avatar

0

As of February 2022, downgrading tot version 303 of pywin32 solves the issue.

Check your pywin32 version:

pip show pywin32

Downgrade to version 300:

pip install pywin32==300 --upgrade

Restart Jupyter

answered Feb 13, 2022 at 9:45

Alberto's user avatar

pypiwin32 is an outdated distribution. Uninstall it and install pywin32:

pip uninstall pypiwin32
pip install pywin32

answered Oct 29, 2019 at 18:53

phd's user avatar

phdphd

77.7k12 gold badges112 silver badges152 bronze badges

4

You should try some (or all) of my methods:

  1. Run terminal and use this command: conda install pywin32.

  2. Copying the two files from [installation directory of Anaconda]Libsite-packagespywin32_system32 (there are only 2 files in this folder) and paste to C:WindowsSystem32.

    In my case, the two files are pythoncom38.dll and pywintypes38.dll (it means my Python version is 3.8).

  3. Downgrading the version of pywin32 to 225 or lower by this command: pip install pywin32==225.

answered Oct 4, 2021 at 4:39

TheHai's user avatar

1

Windows 10, Python 3.8, PyWin32 v.302 using Anaconda

Here is what worked for me

Open an elevated command prompt activate environment

  • Windows Key
  • Type cmd
  • Right click Command Prompt and click Run as Administrator
  • conda activate [ENVIRONMENT]

Navigate to the environment you installed PyWin32 on, works if pip install or conda install is used

  • cd C:Users[USER]anaconda3envs[ENVIRONMENT]Scripts

Run the post install script that was added when installing PyWin32

  • python pywin32_postinstall.py -install

answered Nov 18, 2021 at 18:08

addohm's user avatar

addohmaddohm

2,1282 gold badges12 silver badges37 bronze badges

Yes it works!

C:ProgramDataAnaconda3>py Scriptspywin32_postinstall.py -install

Parsed arguments are: Namespace(destination=’C:ProgramDataAnaconda3Libsite-packages’, install=True, quiet=False, remove=False, silent=False, wait=None)
Copied pythoncom38.dll to C:WINDOWSsystem32pythoncom38.dll
Copied pywintypes38.dll to C:WINDOWSsystem32pywintypes38.dll
Registered: Python.Interpreter
Registered: Python.Dictionary
Registered: Python
-> SoftwarePythonPythonCore3.8Help[None]=None
-> SoftwarePythonPythonCore3.8HelpPythonwin Reference[None]=’C:ProgramDataAnaconda3Libsite-packagesPyWin32.chm’
Registered help file
Pythonwin has been registered in context menu
Creating directory C:ProgramDataAnaconda3Libsite-packageswin32comgen_py
Can’t install shortcuts — ‘C:ProgramDataMicrosoftWindowsStart MenuProgramsPython 3.8’ is not a folder
The pywin32 extensions were successfully installed.

answered Apr 5, 2022 at 0:59

user3761555's user avatar

user3761555user3761555

6976 silver badges19 bronze badges

version 228 works best for me in Windows 10

pip uninstall pywin32
pip install pywin32==228

Sergey Shubin's user avatar

answered Jul 26, 2021 at 13:29

Shivaji fullstack's user avatar

Jupyter notebook github has the issue mentioned in the question. There are multiple solution proposed.

What worked for me was this answer with additional first step:

  1. pip uninstall pywin32
  2. pip install pywin32
  3. python [environment path]/Scripts/pywin32_postinstall.py -install

answered Feb 26, 2021 at 17:21

Vikram's user avatar

VikramVikram

3203 silver badges15 bronze badges

In the referecne to this comment question

where is this Libsite-packagespywin32_system32 path?

Go to C directory, Users , your username , anaconda3 ,Lib, site-packages,pywin32_system32. you can find easily.

C:UsersHPanaconda3Libsite-packagespywin32_system32

Ardent Coder's user avatar

Ardent Coder

3,6979 gold badges28 silver badges51 bronze badges

answered May 23, 2020 at 10:08

Aastha's user avatar

Currently there are two copies of the pythoncom*.dll files in directories.
Pycharm is using the copy in directory C:WindowsSystem32:-

C:WindowsSystem32
C:UserssharandiAppDataLocalProgramsPythonPython38Libsite-packagespywin32_system32

The files are: —
pythoncom38.dll — 559 KB
pywintypes38.dll — 138 KB

answered Aug 22, 2020 at 9:34

Dilip Sharan's user avatar

I downloaded and installed the latest Microsoft Visual C++ 2015-2019 package from
(https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads). You may have to restart your machine after installation.

Then from conda command prompt activate your virtual environment and go to the Scripts folder of the virtual environment(>cd «path of venv»/Scripts)

Once you are in the Scripts folder run the following command
«python pywin32_postinstall.py -install»

This will install the required dll’s to the appropriate folders in the virtual environment.

And that’s how I got it to work!

answered Nov 18, 2020 at 7:29

Raghunath Chandran's user avatar

I have had this issue with Jupyter in Anaconda. After following all listed advices, without clear understanding what I am doing, nothing worked for me except one thing. I have updated indexes of Anaconda environments and I’ve got my kernels back. The screenshot

answered Jun 25, 2021 at 11:45

MaxSM's user avatar

MaxSMMaxSM

112 bronze badges

This problem for me occured when recreating venv from requirements.txt. This venv was initially created on Ubuntu Linux and then recreated on Win 10.

I had to clear the environment and install everyrhing again manually. Did the work for me.

answered Jul 12, 2021 at 23:05

Vojtech Stas's user avatar

Solved

I tried uninstalling and reinstalling pywin32 multiple ways, but the problem persisted. The following way solved the problem:

pip install --upgrade jupyter_client    
pip install --upgrade pywin32==224 --force-reinstall

answered Aug 13, 2021 at 4:56

gourxb's user avatar

gourxbgourxb

3251 gold badge5 silver badges13 bronze badges

hi this question i’m solve as below:
1.check directory C:WindowsSystem32, is exist these file?
pythoncom37.dll pywintypes37.dll or pythoncom36.dll pywintypes36.dll
the number is python version .

  1. if the file is exist delete it.

and then this issue will be solve.

answered Feb 11, 2022 at 8:35

Nguhyw's user avatar

You should go into the folder {python folder path}/Lib/site-packages/pywin32_system32 and copy pythoncomXX.dll and pywintypesXX.dll to the folder C:/Windows/System32.

If you are using a virtual environment, then {python folder path} is the python folder used by the virtual environment, otherwise it is the folder where the global python is located. For example, I use conda to create a virtual environment called Frameless-Window, and install the package pywin32 in this virtual environment, then the {python folder path} on my computer should be D:/Anaconda/envs/Frameless-Window.

You should be very careful when copying the dll to the System32 folder. if there are dlls with the same name in the folder and pywin32 in your other virtual environment may use these two dlls, replacing the original dlls may cause this virtual environment had the same ImportError problem. After testing, I found that the dlls of pywin32 of version 227, 228 and 300 can be replaced with each other, and the dlls of pywin32 of versions 301, 302, 303 and 304 can also be replaced with each other, but if the dll of version 300 is replaced with the dll of version 301, it will raise ImportError.

answered Jun 3, 2022 at 10:46

zhiyi's user avatar

zhiyizhiyi

911 silver badge8 bronze badges

If you are launching a virtual env from another virutal env. Makes sure to install pywin32 in both envs. Lost way too many time with this….

answered Jun 15, 2022 at 14:29

Greg7000's user avatar

Greg7000Greg7000

1712 silver badges14 bronze badges

This worked for me
conda install -c anaconda pywin32

answered Nov 7, 2022 at 18:49

King Chudi's user avatar

Its about venv or virtualenv version problem about pywin32
check version of both of version of pywin32 (pip install pywin32)

than run this command on active venv

pip install --upgrade pywin32==305

answered Dec 21, 2022 at 7:45

Rufai DEMIR's user avatar

Maybe a bit late but it could help:

What happens is that you have two versions of pywin32 installed (One in the local enviroment and the other one in the main python installation)

To solve that uninstall both versions with:

conda uninstall pywin32
pip uninstall pywin32

And inside your virtual conda enviroment also execute:

conda uninstall pywin32
or 
pip uninstall pywin32

finally in your virtual enviroment / conda enviroment install with pip install pywin32 or conda.

The answers telling that it works with x version is because the version they install are compatible with the pywin32 dlls they have in system32.

Adding a support link: «DLL load failed: The specified procedure could not be found» when importing win32api or win32com

answered Jan 4 at 13:05

david.t_92's user avatar

david.t_92david.t_92

1,9111 gold badge10 silver badges15 bronze badges

I had the same issue after reinstalling anaconda 3.9 instead of 3.7 and placing inside the former env folder.

I launched the Anaconda Prompt application then typed in

cd C:Users%USERNAME%anaconda3Scripts
activate.bat

I suspect it updated the pythoncomXX.dll and pywintypesXX.dll used by anaconda.

answered Jan 17 at 14:27

Lokinou's user avatar

LokinouLokinou

9999 silver badges13 bronze badges

That is Simple. After Many Tries, I Discovered a Solution. Just Type the Following Commands in Windows 10. I am Using Pycharm, Python Version 3.9

Note:- This Works for All Python Versions !!

pip uninstall pywin32

pip install pywin32

That is Simple.

if That Does Not Work, Then Try:-

pip uninstall win32api
pip install win32api

After Trying These Commands, Try the first 2 commands again.

If It is Still Not Coming, Then Comment This Question What the problem is !!

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Jul 10, 2021 at 15:14

Hacker--Rohan Raj's user avatar

I’m setting up an autoclicker in Python 3.8 and I need win32api for GetAsyncKeyState but it always gives me this error:

>>> import win32api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing win32api: The specified module could not be found.

I’m on Windows 10 Home 64x. I’ve already tried

pip install pypiwin32

And it successfully installs but nothing changes. I tried uninstalling and re-installing python as well. I also tried installing ‘django’ in the same way and it actually works when I import django, so I think it’s a win32api issue only.

>>> import win32api

I expect the output to be none, but the actual output is always that error ^^

Zoe stands with Ukraine's user avatar

asked Oct 29, 2019 at 17:08

Glxce's user avatar

3

Solved

If you are working in a miniconda on conda environment. You could just install pywin32 using conda instead of pip.

This solved my problem:

conda install pywin32

iGian's user avatar

iGian

10.9k3 gold badges19 silver badges35 bronze badges

answered Oct 14, 2020 at 18:54

Janzaib M Baloch's user avatar

4

For my case, install and reinstall pywin32 doesn’t help. After copied the two files from [installation directory of Anaconda]Libsite-packagespywin32_system32 to C:WindowsSystem32, it works.

My environment is python 3.8 in miniconda. The two files are pythoncom38.dll and pywintypes38.dll.

Gjanetta's user avatar

answered Mar 10, 2020 at 3:05

Bench Wang's user avatar

Bench WangBench Wang

7621 gold badge5 silver badges3 bronze badges

9

For me, it worked by downgrading my pywin32 from version 227 to version 224. Just type the following command on any shell in administrator mode:

pip install --upgrade pywin32==224

Jaroslav Bezděk's user avatar

answered Jun 7, 2020 at 18:28

Aditya Saini's user avatar

11

Run Scriptspywin32_postinstall.py -install in an Admin command prompt

ref: https://github.com/mhammond/pywin32/issues/1431

edit: User @JoyfulPanda gave a warning:

Running this script with admin rights will also copy pythoncom37.dll, pywintypes37.dll (corresponding to the pywin32 version), into C:WINDOWSsystem32, which effectively overwrites the corresponding DLL versions from Anaconda already there. This later causes problem when openning (on Windows) «Start Menu > Anaconda3 (64-bit) > Anaconda Prompt (a_virtual_env_name)». At least Anaconda 2019.07 has pywin32 223 installed by default. Pywin32 224 may work, but 225-228 causes problem for Anaconda (2019.07)

answered Apr 9, 2020 at 20:16

José's user avatar

JoséJosé

1,6541 gold badge16 silver badges21 bronze badges

4

This happens when Libsite-packagespywin32_system32 is not in the list of directories to search for DLL (PATH environment variable).

pywin32 (or one of its dependencies) adds this path at runtime to the PATH variable. If this is failing, or another component is overriding the PATH after it’s been set by pywin32, you will get the given error (ImportError: DLL load failed while importing win32api).

You can try to extend the PATH variable in the shell before starting Python.

On Windows:

set PATH=c:...Libsite-packagespywin32_system32;%PATH%

If that doesn’t work, then the PATH maybe overridden within the Python program at runtime. Add the following line to your program just before pywin32 is used to verify its value:

import os
print(os.environ["PATH"])

As a last resort, you can extend the PATH variable before pywin32 is loaded:

Windows:

os.environ["PATH"] = r"c:...pywin32_system32;" + os.environ["PATH"]

Unix like:

os.environ["PATH"] = r"/.../pywin32_system32:" + os.environ["PATH"]

answered Jul 26, 2020 at 16:40

ocroquette's user avatar

ocroquetteocroquette

2,8991 gold badge20 silver badges25 bronze badges

4

According to pywin32 github you must run

pip install pywin32

and after that, you must run

python pathtopythonScriptspywin32_postinstall.py -install

taken from here. worked for me!

answered Aug 17, 2020 at 15:26

Michael Tamillow's user avatar

3

For python 3.8.3, pywin32==225 worked for me, the existing pywin32==228 was uninstalled.

So try this

pip install pywin32==225

Hope it solves your problem

Jean-François Fabre's user avatar

answered Mar 27, 2021 at 18:24

suhas sasetty's user avatar

1

What helped me was

  1. installing relevant binary from github.com/mhammond/pywin32
  2. executing the following commands in the x64 command line:

cd C:ProgramDataAnaconda3Scripts

python pywin32_postinstall.py -install

answered Jun 7, 2022 at 8:10

Anatoly Alekseev's user avatar

0

As of February 2022, downgrading tot version 303 of pywin32 solves the issue.

Check your pywin32 version:

pip show pywin32

Downgrade to version 300:

pip install pywin32==300 --upgrade

Restart Jupyter

answered Feb 13, 2022 at 9:45

Alberto's user avatar

pypiwin32 is an outdated distribution. Uninstall it and install pywin32:

pip uninstall pypiwin32
pip install pywin32

answered Oct 29, 2019 at 18:53

phd's user avatar

phdphd

77.7k12 gold badges112 silver badges152 bronze badges

4

You should try some (or all) of my methods:

  1. Run terminal and use this command: conda install pywin32.

  2. Copying the two files from [installation directory of Anaconda]Libsite-packagespywin32_system32 (there are only 2 files in this folder) and paste to C:WindowsSystem32.

    In my case, the two files are pythoncom38.dll and pywintypes38.dll (it means my Python version is 3.8).

  3. Downgrading the version of pywin32 to 225 or lower by this command: pip install pywin32==225.

answered Oct 4, 2021 at 4:39

TheHai's user avatar

1

Windows 10, Python 3.8, PyWin32 v.302 using Anaconda

Here is what worked for me

Open an elevated command prompt activate environment

  • Windows Key
  • Type cmd
  • Right click Command Prompt and click Run as Administrator
  • conda activate [ENVIRONMENT]

Navigate to the environment you installed PyWin32 on, works if pip install or conda install is used

  • cd C:Users[USER]anaconda3envs[ENVIRONMENT]Scripts

Run the post install script that was added when installing PyWin32

  • python pywin32_postinstall.py -install

answered Nov 18, 2021 at 18:08

addohm's user avatar

addohmaddohm

2,1282 gold badges12 silver badges37 bronze badges

Yes it works!

C:ProgramDataAnaconda3>py Scriptspywin32_postinstall.py -install

Parsed arguments are: Namespace(destination=’C:ProgramDataAnaconda3Libsite-packages’, install=True, quiet=False, remove=False, silent=False, wait=None)
Copied pythoncom38.dll to C:WINDOWSsystem32pythoncom38.dll
Copied pywintypes38.dll to C:WINDOWSsystem32pywintypes38.dll
Registered: Python.Interpreter
Registered: Python.Dictionary
Registered: Python
-> SoftwarePythonPythonCore3.8Help[None]=None
-> SoftwarePythonPythonCore3.8HelpPythonwin Reference[None]=’C:ProgramDataAnaconda3Libsite-packagesPyWin32.chm’
Registered help file
Pythonwin has been registered in context menu
Creating directory C:ProgramDataAnaconda3Libsite-packageswin32comgen_py
Can’t install shortcuts — ‘C:ProgramDataMicrosoftWindowsStart MenuProgramsPython 3.8’ is not a folder
The pywin32 extensions were successfully installed.

answered Apr 5, 2022 at 0:59

user3761555's user avatar

user3761555user3761555

6976 silver badges19 bronze badges

version 228 works best for me in Windows 10

pip uninstall pywin32
pip install pywin32==228

Sergey Shubin's user avatar

answered Jul 26, 2021 at 13:29

Shivaji fullstack's user avatar

Jupyter notebook github has the issue mentioned in the question. There are multiple solution proposed.

What worked for me was this answer with additional first step:

  1. pip uninstall pywin32
  2. pip install pywin32
  3. python [environment path]/Scripts/pywin32_postinstall.py -install

answered Feb 26, 2021 at 17:21

Vikram's user avatar

VikramVikram

3203 silver badges15 bronze badges

In the referecne to this comment question

where is this Libsite-packagespywin32_system32 path?

Go to C directory, Users , your username , anaconda3 ,Lib, site-packages,pywin32_system32. you can find easily.

C:UsersHPanaconda3Libsite-packagespywin32_system32

Ardent Coder's user avatar

Ardent Coder

3,6979 gold badges28 silver badges51 bronze badges

answered May 23, 2020 at 10:08

Aastha's user avatar

Currently there are two copies of the pythoncom*.dll files in directories.
Pycharm is using the copy in directory C:WindowsSystem32:-

C:WindowsSystem32
C:UserssharandiAppDataLocalProgramsPythonPython38Libsite-packagespywin32_system32

The files are: —
pythoncom38.dll — 559 KB
pywintypes38.dll — 138 KB

answered Aug 22, 2020 at 9:34

Dilip Sharan's user avatar

I downloaded and installed the latest Microsoft Visual C++ 2015-2019 package from
(https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads). You may have to restart your machine after installation.

Then from conda command prompt activate your virtual environment and go to the Scripts folder of the virtual environment(>cd «path of venv»/Scripts)

Once you are in the Scripts folder run the following command
«python pywin32_postinstall.py -install»

This will install the required dll’s to the appropriate folders in the virtual environment.

And that’s how I got it to work!

answered Nov 18, 2020 at 7:29

Raghunath Chandran's user avatar

I have had this issue with Jupyter in Anaconda. After following all listed advices, without clear understanding what I am doing, nothing worked for me except one thing. I have updated indexes of Anaconda environments and I’ve got my kernels back. The screenshot

answered Jun 25, 2021 at 11:45

MaxSM's user avatar

MaxSMMaxSM

112 bronze badges

This problem for me occured when recreating venv from requirements.txt. This venv was initially created on Ubuntu Linux and then recreated on Win 10.

I had to clear the environment and install everyrhing again manually. Did the work for me.

answered Jul 12, 2021 at 23:05

Vojtech Stas's user avatar

Solved

I tried uninstalling and reinstalling pywin32 multiple ways, but the problem persisted. The following way solved the problem:

pip install --upgrade jupyter_client    
pip install --upgrade pywin32==224 --force-reinstall

answered Aug 13, 2021 at 4:56

gourxb's user avatar

gourxbgourxb

3251 gold badge5 silver badges13 bronze badges

hi this question i’m solve as below:
1.check directory C:WindowsSystem32, is exist these file?
pythoncom37.dll pywintypes37.dll or pythoncom36.dll pywintypes36.dll
the number is python version .

  1. if the file is exist delete it.

and then this issue will be solve.

answered Feb 11, 2022 at 8:35

Nguhyw's user avatar

You should go into the folder {python folder path}/Lib/site-packages/pywin32_system32 and copy pythoncomXX.dll and pywintypesXX.dll to the folder C:/Windows/System32.

If you are using a virtual environment, then {python folder path} is the python folder used by the virtual environment, otherwise it is the folder where the global python is located. For example, I use conda to create a virtual environment called Frameless-Window, and install the package pywin32 in this virtual environment, then the {python folder path} on my computer should be D:/Anaconda/envs/Frameless-Window.

You should be very careful when copying the dll to the System32 folder. if there are dlls with the same name in the folder and pywin32 in your other virtual environment may use these two dlls, replacing the original dlls may cause this virtual environment had the same ImportError problem. After testing, I found that the dlls of pywin32 of version 227, 228 and 300 can be replaced with each other, and the dlls of pywin32 of versions 301, 302, 303 and 304 can also be replaced with each other, but if the dll of version 300 is replaced with the dll of version 301, it will raise ImportError.

answered Jun 3, 2022 at 10:46

zhiyi's user avatar

zhiyizhiyi

911 silver badge8 bronze badges

If you are launching a virtual env from another virutal env. Makes sure to install pywin32 in both envs. Lost way too many time with this….

answered Jun 15, 2022 at 14:29

Greg7000's user avatar

Greg7000Greg7000

1712 silver badges14 bronze badges

This worked for me
conda install -c anaconda pywin32

answered Nov 7, 2022 at 18:49

King Chudi's user avatar

Its about venv or virtualenv version problem about pywin32
check version of both of version of pywin32 (pip install pywin32)

than run this command on active venv

pip install --upgrade pywin32==305

answered Dec 21, 2022 at 7:45

Rufai DEMIR's user avatar

Maybe a bit late but it could help:

What happens is that you have two versions of pywin32 installed (One in the local enviroment and the other one in the main python installation)

To solve that uninstall both versions with:

conda uninstall pywin32
pip uninstall pywin32

And inside your virtual conda enviroment also execute:

conda uninstall pywin32
or 
pip uninstall pywin32

finally in your virtual enviroment / conda enviroment install with pip install pywin32 or conda.

The answers telling that it works with x version is because the version they install are compatible with the pywin32 dlls they have in system32.

Adding a support link: «DLL load failed: The specified procedure could not be found» when importing win32api or win32com

answered Jan 4 at 13:05

david.t_92's user avatar

david.t_92david.t_92

1,9111 gold badge10 silver badges15 bronze badges

I had the same issue after reinstalling anaconda 3.9 instead of 3.7 and placing inside the former env folder.

I launched the Anaconda Prompt application then typed in

cd C:Users%USERNAME%anaconda3Scripts
activate.bat

I suspect it updated the pythoncomXX.dll and pywintypesXX.dll used by anaconda.

answered Jan 17 at 14:27

Lokinou's user avatar

LokinouLokinou

9999 silver badges13 bronze badges

That is Simple. After Many Tries, I Discovered a Solution. Just Type the Following Commands in Windows 10. I am Using Pycharm, Python Version 3.9

Note:- This Works for All Python Versions !!

pip uninstall pywin32

pip install pywin32

That is Simple.

if That Does Not Work, Then Try:-

pip uninstall win32api
pip install win32api

After Trying These Commands, Try the first 2 commands again.

If It is Still Not Coming, Then Comment This Question What the problem is !!

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Jul 10, 2021 at 15:14

Hacker--Rohan Raj's user avatar

I created a project yesterday evening with 3.8.2 and ran into this problem. Error can be found below.
This morning I did a new venv with 3.7.6, exact same setup besides that, and there was no issue.

One remark… When installing the package on python38 (the -binary), it seems to compile it… But not on python37…
Installing psycopg2-binary on python37: https://gist.github.com/tobiasgardner/57ac84e45c8c5502ea5682852e300a31
Installing psycopg2-binary on python38: https://gist.github.com/tobiasgardner/7f93fcd22e413b525833adfe75c54d92

C:UserstobbeAppDataLocalJetBrainsToolboxappsPyCharm-Pch-0193.6494.30binrunnerw64.exe C:UserstobbeDocumentsgit-reposecombooster.venvScriptspython.exe C:/Users/tobbe/Documents/git-repos/ecombooster/manage.py runserver 8000 Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:Program FilesPython38libthreading.py", line 932, in _bootstrap_inner self.run() File "C:Program FilesPython38libthreading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangoutilsautoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangocoremanagementcommandsrunserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangoutilsautoreload.py", line 76, in raise_last_exception raise _exception[1] File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangocoremanagement__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangoutilsautoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjango__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangoappsregistry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangoappsconfig.py", line 116, in create mod = import_module(mod_path) File "C:Program FilesPython38libimportlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagesdjangocontribpostgresapps.py", line 4, in <module> from psycopg2.extras import DateRange File "C:UserstobbeDocumentsgit-reposecombooster.venvlibsite-packagespsycopg2__init__.py", line 50, in <module> from psycopg2._psycopg import ( # noqa ImportError: DLL load failed while importing _psycopg: The specified module could not be found.

  • Partition Wizard

  • Partition Manager

  • How to Fix Python ImportError: Dll Load Failed Error

By Linda | Follow |
Last Updated December 06, 2022

If you use Python, you may have ever received error «ImportError: Dll Load Failed: The specified module could not be found.» In this post, MiniTool Partition Wizard shows you how to solve this error through 2 methods.

Module Not Found Error Python

Python is a widely used interpreted, high-level and general-purpose programming language. As a successor to the ABC language, it replaces the Unix shell and C language for system management, and is responsible for the interaction with the Amoeba operating system and exception handling.

The Python interpreter itself can run on almost all operating systems. Many users may use it on a Windows computer. But some users report that they have encountered module not found error Python. The error usually gives you the following message: ImportError: Dll Load Failed: The specified module could not be found.

In most cases, the «ImportError: Dll Load Failed: The specified module could not be found» error will occur when you import Python libraries including TensorFlow, Numpy, Keras, Pandas, PySide2, etc. Sometimes, when you execute programs related to these libraries, the error may also occur.

How to Fix the Python ImportError: Dll Load Failed Error

What to do if you get error message «ImportError: Dll Load Failed: The specified module could not be found»? You can try the following methods.

Fix 1. Reinstall Library

In most cases, the error occurs when you import a library. The cause of the error may be incorrect/incomplete installation or incompatibility of the library. In this case, you can try reinstalling the library to see whether the problem can be solved. Please refer to the following steps:

Step 1: Identify the library that causes the error «ImportError: Dll Load Failed: The specified module could not be found.» Usually, you can find the culprit in the output lines just above the error.

Step 2: You can use the following commands to uninstall and install a library (numpy is the name of a Python library).

  • pip uninstall numpy
  • pip install numpy

Sometimes, the library may be outdated and you need to install the latest version. In this case, you should uninstall the library first, then update the pip, and finally install the library again.

Besides, if the error occurs, because the module is too new, you can solve the problem by installing the module with a specified version.

How to Fix PIP Is Not Recognized in Windows Command Prompt?

Fix 2. Configure Environment Variables

If the above method can’t solve the problem, you should check whether the environment variables are set correctly. Sometimes, the environment variables may change without reasons. In this case, you should configure the environment variables again. Please refer to the following steps:

Step 1: Identify which Python distribution you are using (e.g. Anaconda).

Step 2: Right-click on My Computer/This PC icon and choose Properties. Click Advanced system settings > Environment Variables. Click Path variable under User variables box or System variables box. Click the corresponding Edit button.

Note: If you choose Path under the user variables box, it means these variables are only applied for current user account. If you choose Path under the system variables box, it means that these variables are applied for all user accounts.

Step 3: A new window will pop up. Then, click New button to add the following 3 variables:

  • X:ProgramDataAnaconda3
  • X:ProgramDataAnaconda3Scripts
  • X:ProgramDataAnaconda3Librarybin

Note: You should change the path according to your condition.

add environment variables

Then, you should check whether the problem is solved.

About The Author

Linda

Position: Columnist

Author Linda has been working as an editor at MiniTool for 1 year. As a fresh man in IT field, she is curious about computer knowledge and learns it crazily. Maybe due to this point, her articles are simple and easy to understand. Even people who do not understand computer can gain something.

By the way, her special focuses are data recovery, partition management, disk clone, and OS migration.

This article will tell you how to fix the ImportError: DLL load failed while importing _sqlite3: The specified module could not be found when you run eclipse to develop a python project through PyDev with the anaconda virtual environment. The error happens on Windows OS.

1. Reproduce the ImportError: DLL load failed while importing _sqlite3: The specified module could not be found steps.

  1. Install anaconda on windows, you can read the article How To Install Anaconda On Linux, Windows, macOS Correctly.
  2. Create a python virtual environment in Anaconda, you can read the article How To Manage Anaconda Environments.
  3. Create an eclipse PyDev project, please read the article How To Run Python In Eclipse With PyDev.
  4. Run the source code in the article How To Use Python To Insert, Delete, Update, Query Data In SQLite DB Table.
  5. When you run the example source code, the first line of code import sqlite3 will throw the below error.
    Traceback (most recent call last):
      File "C:WorkSpaceWorkdev2qa.com-example-codePythonExampleProjectcomdev2qaexamplesqliteSQLiteOperationExample.py", line 8, in <module>
        import sqlite3
      File "C:Userszhaosonganaconda3envspython_examplelibsqlite3__init__.py", line 23, in <module>
        from sqlite3.dbapi2 import *
      File "C:Userszhaosonganaconda3envspython_examplelibsqlite3dbapi2.py", line 27, in <module>
        from _sqlite3 import *
    ImportError: DLL load failed while importing _sqlite3: The specified module could not be found.

2. How to fix the ImportError: DLL load failed while importing _sqlite3: The specified module could not be found steps.

  1. Open a windows explorer in Windows OS, right-click the This PC icon on the left side, click the Properties menu item in the popup menu list.
  2. On the popup System window right side, you can find your Windows OS system type ( x86 or x64 ) in the System —> System type section.
  3. Download the SQLite DLL library file from the URL https://www.sqlite.org/download.html according to your Windows OS system type.
  4. Unzip the download file into a local folder, there are two files in the unzip folder sqlite3.dll and sqlite3.def.
  5. Open the anaconda navigator window by clicking the Windows start menu —> Anaconda3(64-bit) —> Anaconda Navigator(anaconda3).
  6. Click the Environments menu item on the anaconda navigator popup window left side, select your python virtual environment on the center, and click the green arrow button at the end of the python virtual environment, then click the Open Terminal menu item on the popup menu list.
  7. Input command pip -V in the popup dos window, then it will return the anaconda python virtual environment installed directory path.
    (python_example) C:Userszhaosong>pip -V
    pip 20.2.2 from C:Userszhaosonganaconda3envspython_examplelibsite-packagespip (python 3.8)
  8. Copy the files sqlite3.dll and sqlite3.def to the directory C:Userszhaosonganaconda3envspython_exampleDLLs in this example. In this example, the anaconda python virtual environment name is python_example.
  9. Now you will find you can run the python source code in your eclipse PyDev project.
  10. You can also copy the sqlite3.dll and sqlite3.def to the directory C:Userszhaosonganaconda3DLLs, if you do like this, you need to add the directory path C:Userszhaosonganaconda3DLLs to the PyDev —> PYTHONPATH —> External Libraries in eclipse PyDev project properties window. You can read the article How To Add Library In Python Eclipse Project to learn more.

importerror: dll load failed: The specified module could not be found error occurs because of the incompatibilities of Microsoft Visual C++ (Visual Studio) versions.  The best way to fix this error (importerror: dll load failed) is to reinstall/ install the Microsoft Visual C++ distribution. Apart from this, sometimes manually adding the dll files also fix this error. Let’s explore these methods one by one.

Here we are adding a few methods to fix the error (importerror: dll load failed ). Please apply them one by one.

Method 1:  reinstall the Microsoft Visual c++

Here is the link for downloading Microsoft Visual c++. It will come as a group of dll files. You may try different distribution versions between ( Visual Studio 2015, 2017, and 2019 ). In most of cases, this step will fix  the error (importerror: dll load failed)

importerror dll load failed
importerror dll load failed

Method 2: Manually adding required dlls –

In the previous step, We have reinstalled the Microsoft Visual c++ completely.  But we can also fix the above error if we only replace the required DLLs. Please follow the below steps for this.

  1. Download the msvcp71.dll file.
  2. Save the file at the C:WindowsSystem32 location.
  3. In the case of 64-bit OS, Please save the same file in the C:WindowsSysWOW64 location.

You may also try the msvcr71.dll file in the place of the above DLL file.

Method 3:  Reinstalling the Python package (blocker) with Python –

We are getting this error, because of some python packages with underline incompatible libraries. Hence we replace the existing python with the latest or compatible one. Then reinstall the libraries on top of it. To install libraries use the pip3 or pip command depending upon the versions of python.

If your python version is 3. xx then use the pip3 otherwise use pip for python 2.xx.

For example, I want to install the “X” library then I will use the below command.

pip3 install X

Conclusion –

I hope the above step will fix the error for you. But in case any of the above steps are not working, please let us know. You may comment on the details of this error in the comment box. We will help you in resolving them.

Thanks 

Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

We respect your privacy and take protecting it seriously

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to use numpy array And I am facing following error ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Contents

  1. How this Error Occurs ?
  2. How To Solve ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found Error ?
  3. Solution 1: Reinstall numpy
  4. Summary

How this Error Occurs ?

I am trying to use numpy array And I am facing following error.

Traceback (most recent call last):
File “f:python38libsite-packagesnumpycore__init__.py”, line 24, in from .
import multiarray
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “F:PCSDocumentsPythonnumpytest.py”, line 9, in
import numpy as np
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
– Try uninstalling and reinstalling numpy.
– If you have already done that, then:

  1. How To Solve ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found Error ?

    To Solve ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found Error You just need to reinstall numpy using setuptools. Use this command. First of all uninstall numpy using this command. pip uninstall -y numpy. Then uninstall setuptools with this command. pip uninstall -y setuptools. Now, Reinstall setuptools with this command. pip install setuptools. Then, You can reinstall numpy with this command. pip install numpy. Now, Your error must be solved.

  2. ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found

    To Solve ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found Error You just need to reinstall numpy using setuptools. Use this command. First of all uninstall numpy using this command. pip uninstall -y numpy. Then uninstall setuptools with this command. pip uninstall -y setuptools. Now, Reinstall setuptools with this command. pip install setuptools. Then, You can reinstall numpy with this command. pip install numpy. Now, Your error must be solved.

Solution 1: Reinstall numpy

You just need to reinstall numpy using setuptools. Use this command. First of all uninstall numpy using this command.

pip uninstall -y numpy

Then uninstall setuptools with this command.

pip uninstall -y setuptools

Now, Reinstall setuptools with this command.

pip install setuptools

Then, You can reinstall numpy with this command.

pip install numpy

Now, Your error must be solved.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

  • Original error was: DLL load failed: The specified module could not be found

Понравилась статья? Поделить с друзьями:
  • Importer mpeg error premiere
  • Import yaml error
  • Import validation error django
  • Import tensorflow as tf ошибка
  • Import tensorflow as tf error