Python version for UQpyLab

Hi,
I have recently started to use the UQpyLab framework and firstly would like to say great work! with these very comprehensive and detailed packages (in matlab and python) you’ve developed :smiley:

I wish to combine UQpylab with another package (developed in python) for reliability analysis of floating wind turbines, the latter being with a python version β€˜3.12.5’, while UQpylab β€˜s default installation (β€œ>=3.9” from the getting started page) is 3.9.23.

With this I noticed that UQpylab doesnt work when upgraded to a higher python version and gives the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\core\__init__.py:24
     23 try:
---> 24     from . import multiarray
     25 except ImportError as exc:

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\core\multiarray.py:10
      9 import functools
---> 10 from . import overrides
     11 from . import _multiarray_umath

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\core\overrides.py:8
      7 from .._utils._inspect import getargspec
----> 8 from numpy.core._multiarray_umath import (
      9     add_docstring,  _get_implementing_args, _ArrayFunctionDispatcher)
     12 ARRAY_FUNCTIONS = set()

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\__init__.py:159
    158 try:
--> 159     from numpy.__config__ import show as show_config
    160 except ImportError as e:

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\__config__.py:4
      3 from enum import Enum
----> 4 from numpy.core._multiarray_umath import (
      5     __cpu_features__,
      6     __cpu_baseline__,
      7     __cpu_dispatch__,
      8 )
     10 __all__ = ["show"]

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\core\__init__.py:50
     27     msg = """
     28 
     29 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
   (...)
     48 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     49         __version__, exc)
---> 50     raise ImportError(msg)
     51 finally:

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.12 from "c:\Users\vasudevg\.conda\envs\uqpylab-env\python.exe"
  * The NumPy version is: "1.26.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'


The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
File m:\Vasudev_Gupta\Python_Files\UQpyLab\examples\01_probab_input_modelling\Input-1-Sampling.py:2
      1 # %%
----> 2 from uqpylab import sessions
      3 import matplotlib.pyplot as plt
      4 from uqpylab.display_util import get_uq_color_order

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\uqpylab\sessions.py:1
----> 1 import uqpylab.helpers as helpers
      2 import uqpylab.interface as interface
      3 import json

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\uqpylab\helpers.py:2
      1 import pdb
----> 2 import scipy.io as spio
      3 from importlib import import_module,util
      4 import uqpylab.display_util as display_util

File ~\AppData\Roaming\Python\Python312\site-packages\scipy\__init__.py:60
     56 # end delvewheel patch
     58 import importlib as _importlib
---> 60 from numpy import __version__ as __numpy_version__
     63 try:
     64     from scipy.__config__ import show as show_config

File c:\Users\vasudevg\.conda\envs\uqpylab-env\Lib\site-packages\numpy\__init__.py:164
    160 except ImportError as e:
    161     msg = """Error importing numpy: you should not try to import numpy from
    162     its source directory; please exit the numpy source tree, and relaunch
    163     your python interpreter from there."""
--> 164     raise ImportError(msg) from e
    166 __all__ = [
    167     'exceptions', 'ModuleDeprecationWarning', 'VisibleDeprecationWarning',
    168     'ComplexWarning', 'TooHardError', 'AxisError']
    170 # mapping of {name: (value, deprecation_msg)}

ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

UQpylab with python version 3.9.23 works smoothly.

Could you please clarify why this is the case, and some possibilities UQpylab could be run in a updated python version?

Thank you :smiley:

Hi @ibrahim_hanif,

From the traceback, it looks like NumPy is being imported from your virtual environment, while SciPy is being imported from your global Python installation. I would recommend creating a fresh virtual environment (using your preferred Python version) and reinstalling uqpylab , numpy , and scipy from scratch within that environment only. Maybe that already solves your issue.

Best regards,
Styfen

1 Like

Hi @styfen.schaer ,

thank you for your assistance, your suggestion worked well :slight_smile:

there is something in addition I want to do, which is to install uqpylab in an existing (not fresh new) virtual environment, which has in it some packages already installed. I tried this but came across an error

(uqpylab-wisdem-env) M:\Vasudev_Gupta\RBDO_WISDEM>pip install uqpylab
Collecting uqpylab
  Downloading uqpylab-1.0.2-py3-none-any.whl.metadata (2.2 kB)
Collecting appdirs>=1.4.4 (from uqpylab)
  Downloading appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)
Requirement already satisfied: ipython>=8.7.0 in C:\Users\vasudevg\AppData\Roaming\Python\Python314\site-packages (from uqpylab) (9.14.1)
Collecting ipywidgets>=8.0.4 (from uqpylab)
  Downloading ipywidgets-8.1.8-py3-none-any.whl.metadata (2.4 kB)
Requirement already satisfied: matplotlib>=3.5.2 in C:\Users\vasudevg\AppData\Local\anaconda3\envs\uqpylab-wisdem-env\Lib\site-packages (from uqpylab) (3.10.9)
Collecting numpy<2,>=1.21.6 (from uqpylab)
  Downloading numpy-1.26.4.tar.gz (15.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.8/15.8 MB 13.2 MB/s  0:00:01
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  Γ— Preparing metadata (pyproject.toml) did not run successfully.
  β”‚ exit code: 1
  ╰─> [21 lines of output]
      + C:\Users\vasudevg\AppData\Local\anaconda3\envs\uqpylab-wisdem-env\python.exe C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8\vendored-meson\meson\meson.py setup C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8 C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8\.mesonpy-lhv6j6ho -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8\.mesonpy-lhv6j6ho\meson-python-native-file.ini
      The Meson build system
      Version: 1.2.99
      Source dir: C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8
      Build dir: C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8\.mesonpy-lhv6j6ho
      Build type: native build
      Project name: NumPy
      Project version: 1.26.4
      C compiler for the host machine: cc (gcc 15.2.0 "cc (conda-forge gcc 15.2.0-19) 15.2.0")
      C linker for the host machine: cc ld.bfd 2.45.1
      
      ..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['c++'], ['g++'], ['clang++'], ['clang-cl']]
      The following exception(s) were encountered:
      Running `icl ""` gave "[WinError 2] The system cannot find the file specified"
      Running `cl /?` gave "[WinError 2] The system cannot find the file specified"
      Running `c++ --version` gave "[WinError 2] The system cannot find the file specified"
      Running `g++ --version` gave "[WinError 2] The system cannot find the file specified"
      Running `clang++ --version` gave "[WinError 2] The system cannot find the file specified"
      Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified"
      
      A full log can be found at C:\Users\vasudevg\AppData\Local\Temp\pip-install-18_cukdj\numpy_6803d4c31fb04799a8e1075a130bcfb8\.mesonpy-lhv6j6ho\meson-logs\meson-log.txt
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> numpy

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

(uqpylab-wisdem-env) M:\Vasudev_Gupta\RBDO_WISDEM>conda list gcc     
# packages in environment at C:\Users\vasudevg\AppData\Local\anaconda3\envs\uqpylab-wisdem-env:
#
# Name                    Version                   Build  Channel
gcc                       15.2.0              h6123e3b_19    conda-forge
gcc_impl_win-64           15.2.0              h062b9a2_19    conda-forge
libgcc                    15.2.0              h8ee18e1_19    conda-forge
libgcc-devel_win-64       15.2.0             hbb59886_119    conda-forge

(uqpylab-wisdem-env) M:\Vasudev_Gupta\RBDO_WISDEM>conda list uqpylab
# packages in environment at C:\Users\vasudevg\AppData\Local\anaconda3\envs\uqpylab-wisdem-env:
#
# Name                    Version                   Build  Channel

could you please direct me on how this could be achieved? thank you :smiley:

Hi @ibrahim_hanif,

The issue is that uqpylab requires numpy<2, as indicated in the traceback. The latest NumPy release in the 1.x series is NumPy 1.26.4. However, it appears that you are using Python 3.14, for which NumPy 1.26.4 is not distributed as a precompiled package.

As a result, pip attempts to build NumPy from source. This build process requires a compatible compiler toolchain, and the compilation fails in your environment, which prevents the installation from completing.

Unfortunately, this means that there is currently no straightforward way to install uqpylab in this particular environment.

Best regards,
Styfen

1 Like