Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator numpy import
Forum Updated to NodeBB v4.3 + New Features

QtCreator numpy import

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
1 Posts 1 Posters 656 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ollarch
    wrote on 17 May 2021, 15:45 last edited by
    #1

    Hi,

    I have installed (Windows 10):
    Qt 5.15.2
    QtCreator 4.14.2

    I also installed Miniconda and created a virtual environment "dl_v1" where I installed PySide2 using pip and Numpy 1.20.2 using conda command.

    I created a new Python Project on QtCreator. I configured the Python interpreter to use the new created environment. This application only shows the main window.

    When trying to import numpy library I get this error:

    17:06:03: Starting E:\Miniconda3\envs\dl_v1\python.exe -u "E:\Test001\main.py"...
    Traceback (most recent call last):
      File "E:\Miniconda3\envs\dl_v1\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
        from . import multiarray
      File "E:\Miniconda3\envs\dl_v1\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
        from . import overrides
      File "E:\Miniconda3\envs\dl_v1\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
        from numpy.core._multiarray_umath import (
    ImportError: DLL load failed while importing _multiarray_umath: No se puede encontrar el módulo especificado.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "E:\Test001\main.py", line 5, in <module>
        import numpy as np
      File "E:\Miniconda3\envs\dl_v1\lib\site-packages\numpy\__init__.py", line 145, in <module>
        from . import core
      File "E:\Miniconda3\envs\dl_v1\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
        raise ImportError(msg)
    ImportError: 
    
    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.9 from "E:\Miniconda3\envs\dl_v1\python.exe"
      * The NumPy version is: "1.20.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: No se puede encontrar el módulo especificado.
    
    17:06:04: E:\Miniconda3\envs\dl_v1\python.exe exited with code 1
    

    Finally I tested to run it using command line and it works without any error. I also have tryied to run it using Visual Studio Code and it also works (just an empty main window).

    The code is this. I anly added the import of numpy lib.

    # This Python file uses the following encoding: utf-8
    import sys
    import os
    
    import numpy as np
    
    from PySide2.QtWidgets import QApplication, QMainWindow
    from PySide2.QtCore import QFile
    from PySide2.QtUiTools import QUiLoader
    
    
    class DLTest001(QMainWindow):
        def __init__(self):
            super(DLTest001, self).__init__()
            self.load_ui()
    
        def load_ui(self):
            loader = QUiLoader()
            path = os.path.join(os.path.dirname(__file__), "form.ui")
            ui_file = QFile(path)
            ui_file.open(QFile.ReadOnly)
            loader.load(ui_file, self)
            ui_file.close()
    
    if __name__ == "__main__":
        app = QApplication([])
        widget = DLTest001()
        widget.show()
        sys.exit(app.exec_())
    

    Is there something that I'm missing?

    Thanks,

    1 Reply Last reply
    0

    1/1

    17 May 2021, 15:45

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved