Open juavid opened 1 year ago
It should work with Python version > 3.6. Nothing special is required.
Something that can go wrong is the path where Nomad libraries are located. Here are some checks that I did on my computer. Please note, the last element in the %PATH% variable, this is where the Nomad libraries have been put when building with mingw tools (it will be different for Visual Studio).
There are several tricky things when building/import PyNomad. One is the compatibility between the compiler and the Python version. For example, in my case (OSX), I have
_(base) christophe@Fol-de-Dol nomad4devCopy2 % python Python 3.9.7 (default, Sep 16 2021, 08:50:36) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.
So I need to build nomad with Clang. But the right architecture must be selected ('arm64' or 'x86_64'). I can force x86_64 by adding a build flag like -DCMAKE_OSX_ARCHITECTURES=x86_64 when configuring with cmake.
When importing PyNomad in Python is not working another option exists.
Nomad can optimize on a Python blackbox without using the PyNomad interface in batch mode (see user guide). A simple example is provided.
bb.py
import sys
import os
import re
input_file_name=sys.argv[1]
with open(input_file_name,'r') as openfile:
line = openfile.read().strip()
X = re.sub('\s+',' ',line).strip().split()
openfile.close()
dim = 5
f = float(X[4])
g1 = sum([(float(X[i])-1)**2 for i in range(dim)])-25
g2 = 25-sum([(float(X[i])+1)**2 for i in range(dim)])
print(f,g1,g2)
That is a good solution, thanks for the help, I have tried with VS17 and VS16 and two different PCs. I identified at least one potential problem related to setuptools>60.0.0.
but even then the problem remains. There are some warning messages as well during the compilation but they seem to also appear when I compile it for python 3.6. I was wondering what would be the recommended compiler for Windows?
Visual Studio 15 works for me when building PyNomad. I tried with MinGW and it is not working as is.
Has someone found the causes of this problem? I am using Visual Studio 2022 as a complier, and Python 3.10.12. It produces this error message when importing PyNomad from Python. I used DependenciesGUI to find the missing DLL but no one of them seems missing. The path should be correct since i can correctly call nomad from my CMD.
Furthermore, I checked the architecture and it is correct AMD64, both in the .pyd and in my computer
Thank you in advance!
The building procedure has changed for release v.4.4.0. Maybe it can help solving the problem. Also, PyNomad binaries are now available at https://pypi.org/project/PyNomadBBO/
I have tested PyNomad successfully with Python 3.6 but when I try to install it in Python version >3.6 I get the following error after installing it when trying to import the PyNomad library.
import PyNomad
ImportError: DLL load failed while importing PyNomad: The specified module could not be found.
Is there is any workaround to make it work in Python version >3.6?
Thanks in advanced.