How To Fix Importerror: Unable To Import Required Dependencies When Execute Eclipse Pydev Project

When I use eclipse PyDev to develop a python program, I need to import the python pandas library with the command import pandas as pd. But when I run the python source code in the eclipse PyDev project, it displays the below error messages in the eclipse console. This article will tell you how to fix it.

1. ImportError: Unable To Import Required Dependencies Error Message.

  1. Below is the detailed error message in my environment.
    C:\Users\zhaosong\anaconda3\Lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
      from . import _distributor_init
    Traceback (most recent call last):
      File "D:\Work\dev2qa.com-example-code\PythonExampleProject\com\dev2qa\example\pandas\SeriesExample.py", line 7, in <module>
        import pandas as pd
      File "C:\Users\zhaosong\anaconda3\Lib\site-packages\pandas\__init__.py", line 16, in <module>
        raise ImportError(
    ImportError: Unable to import required dependencies:
    numpy: 
    
    IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
    
    Importing the numpy C-extensions failed. This error can happen for
    many reasons, often due to issues with your setup or how NumPy was
    installed.
    
    We have compiled some common reasons and troubleshooting tips at:
    
        https://numpy.org/devdocs/user/troubleshooting-importerror.html
    
    Please note and check the following:
    
      * The Python version is: Python3.8 from "C:\Users\zhaosong\anaconda3\python.exe"
      * The NumPy version is: "1.19.2"
    
    and make sure that they are the versions you expect.
    Please carefully study the documentation linked above for further help.
    
    Original error was: DLL load failed while importing _multiarray_umath: \u627e\u4e0d\u5230\u6307\u5b9a\u7684\u6a21\u5757\u3002
  2. From the above error message, we can see that it can not find the dependencies library numpy in the current Python interpreter.
  3. So we should check whether the Python interpreter that is used by the python PyDev project installed the numpy library or not.

2. Install Required Python Library On The Eclipse PyDev Project Used Python Interpreter.

  1. First, you should get which python interpreter that your eclipse Pydev project is using. You can read the article How To Change Python Interpreter In Eclipse Pydev Project To Use Different Python Virtual Environment Library
  2. Then you can install the python pandas module on it, you can read the article How To Install Python Library ( such as Pandas ) In PyCharm, PyDev Eclipse to learn more.
  3. If you find this method does not take effect, you can edit your eclipse PyDev project’s .pydevproject file ( you can find this file in the eclipse PyDev python project root folder )
  4. And then replace the pydev_pathproperty name=”org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH” path value to the correct python interpreter packages folder.
  5. Below is the full source code of the .pydevproject file.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <?eclipse-pydev version="1.0"?><pydev_project>
    
        <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
                                                                                            
            <path>/${PROJECT_DIR_NAME}</path>   
        
        </pydev_pathproperty>
                                                    
        <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
            
        <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
        
        <pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">                 
            
            <path>
                C:\Users\zhaosong\anaconda3\Lib\site-packages
                <!--C:\Users\zhaosong\anaconda3\envs\MyPythonEnv\Lib\site-packages-->
            </path>
    
        </pydev_pathproperty>
    
    </pydev_project>
    

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Clicky