首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装NLopt - Python

安装NLopt - Python
EN

Stack Overflow用户
提问于 2018-05-18 00:14:16
回答 1查看 1.1K关注 0票数 2

我对编程很陌生,所以我会尽量让自己明白:

我想安装NLopt库(https://nlopt.readthedocs.io/en/latest/),以便在学术项目中使用它,但我总是会出错。

该包附带的“自述窗口”文件中写着:

这个.zip存档包含DLL库以及为Win64编译的NLopt的关联头(.h)和模块定义(.def)文件。 为了链接到Visual中的这个.dll文件,您需要为它创建一个.lib“导入库”,并且可以使用VC++附带的"lib“命令来实现。特别是,run: lib /def:libnlopt-0.def 要编译Matlab插件,请在Matlab子目录中的文件nlopt_optimize.c (确保链接到libnlopt )上使用matlab "mex“编译器。 要构建Python插件(假设您已经安装了Python和Numpy ),请执行: python setup.py build_ext -inplace 它们是由GNU编译器为MinGW编译的,具体而言: x86_64-w64-mingw32-gcc (GCC) 4.6.3

我已经成功地创建了.lib文件,但是当我在anaconda提示符中执行"python setup.py build_ext --inplace“命令时,我得到了以下错误:

代码语言:javascript
复制
(base) C:\Users\Germano\nlopt>python setup.py build_ext --inplace
running build_ext
building '_nlopt' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe /c     /nologo /Ox /W3 /GL /DNDEBUG /MD -I. -IC:\Users\Germano\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\Germano\Anaconda3\include -IC:\Users\Germano\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /EHsc /Tpnlopt-python.cpp /Fobuild\temp.win-amd64-3.6\Release\nlopt-python.obj
nlopt-python.cpp
c:\users\germano\nlopt\nlopt.hpp(414): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(443): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(473): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\germano\nlopt\nlopt.hpp(483): warning C4267: 'argument': conversion from 'size_t' to 'unsigned int', possible loss of data
nlopt-python.cpp(5249): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(5256): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(8406): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8411): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8466): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(8467): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(8475): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(8480): warning C4101: '_e': unreferenced local variable
nlopt-python.cpp(9443): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(9444): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(9784): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(9785): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10357): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10358): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10496): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10497): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(10763): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(10764): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(11012): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(11013): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(11493): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(11494): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12060): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12061): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12170): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12171): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12240): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12241): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
nlopt-python.cpp(12367): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
nlopt-python.cpp(12368): warning C4244: 'initializing': conversion from 'npy_intp' to 'int', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Germano\Anaconda3\libs /LIBPATH:C:\Users\Germano\Anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64" libnlopt-0.lib /EXPORT:PyInit__nlopt build\temp.win-amd64-3.6\Release\nlopt-python.obj /OUT:C:\Users\Germano\nlopt\_nlopt.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.lib
Creating library build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\_nlopt.cp36-win_amd64.exp
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_algorithm
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_remove_equality_constraints
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_lower_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_munge
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_ftol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_population
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_maxtime
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_copy
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_maxtime
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_abs1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_xtol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_stopval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_ftol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_version
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_population
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_ftol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_max_objective
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_initial_step1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_lower_bounds1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_maxeval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_inequality_constraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_local_optimizer
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_inequality_mconstraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_srand
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_dimension
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_force_stop
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_xtol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_algorithm_name
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_maxeval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_default_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_remove_inequality_constraints
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_vector_storage
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_stopval
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_upper_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_rel
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_srand_time
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_upper_bounds1
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_equality_constraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_ftol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_xtol_abs
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_create
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_vector_storage
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_destroy
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_lower_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_upper_bounds
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_initial_step
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_set_min_objective
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_get_force_stop
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_add_equality_mconstraint
nlopt-python.obj : error LNK2001: unresolved external symbol __imp_nlopt_optimize
C:\Users\Germano\nlopt\_nlopt.cp36-win_amd64.pyd : fatal error LNK1120: 51 unresolved externals
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

(base) C:\Users\Germano\nlopt>

就像我说的,我对编程很陌生,所以这一切对我来说都没有什么意义。我一直在谷歌寻找它,但没有成功。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-20 02:13:28

结果,我使用了错误的VisualC++提示符,更改为正确的提示解决了问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50402092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档