QuantEcon / rvlib

Distributions for Python
http://quantecon.github.io/rvlib/
BSD 3-Clause "New" or "Revised" License
46 stars 10 forks source link

How to install rvlib? #29

Open guilherber opened 2 years ago

guilherber commented 2 years ago

I'm trying to install the rvlib on windows, but im finding some issues, this occur when python is building wheel for rvlib Why im getting this error? Im already installed VS 14.0 How can i fix this "pragma warning" error? I'm also have the VS building tools 2015.


ERROR: Failed building wheel for rvlib
Running setup.py clean for rvlib
Failed to build rvlib
 running install
 c:\users\user\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

 cl : Command line warning D9002 : ignoring unknown option '-std=c99'
 rvlib._rmath_ffi.c
 include\Rconfig.h(16): warning C4005: 'HAVE_HYPOT': macro redefinition
 c:\users\user\appdata\local\programs\python\python38\include\pyconfig.h(61): note: see previous definition of 'HAVE_HYPOT'
 C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc -Iinclude -Ic:\users\user\appdata\local\programs\python\python38\include -Ic:\users\user\appdata\local\programs\python\python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt" /Tcsrc\bd0.c /Fobuild\temp.win-amd64-3.8\Release\src\bd0.obj -DMATHLIB_STANDALONE -std=c99
 cl : Command line warning D9002 : ignoring unknown option '-std=c99'
 bd0.c
 C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\stdarg.h(13): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\stdarg.h(14): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\stdarg.h(29): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_stdio_config.h(12): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_stdio_config.h(13): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_stdio_config.h(131): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(15): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(16): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1130): warning C4996: '_vsnwprintf_l': This function or variable may be unsafe. Consider using _vsnwprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1640): warning C4996: '_vsnwprintf_l': This function or variable may be unsafe. Consider using _vsnwprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1662): warning C4996: '_vsnwprintf_l': This function or variable may be unsafe. Consider using _vsnwprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1797): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1798): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(1854): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(2094): warning C4996: '_vsnwscanf_l': This function or variable may be unsafe. Consider using _vsnwscanf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(2116): warning C4996: '_vsnwscanf_l': This function or variable may be unsafe. Consider using _vsnwscanf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\corecrt_wstdio.h(2171): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(15): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(16): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1412): warning C4996: '_vsnprintf_l': This function or variable may be unsafe. Consider using _vsnprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1459): warning C4996: '_vsnprintf_l': This function or variable may be unsafe. Consider using _vsnprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1474): warning C4996: '_vsnprintf_l': This function or variable may be unsafe. Consider using _vsnprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1755): warning C4996: '_vsprintf_l': This function or variable may be unsafe. Consider using _vsprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1776): warning C4996: '_vsprintf_l': This function or variable may be unsafe. Consider using _vsprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1899): warning C4996: '_vsnprintf_l': This function or variable may be unsafe. Consider using _vsnprintf_s_l instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2192): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2193): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2216): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2300): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2301): warning C4068: unknown pragma 'Rf_warning'
 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(2398): warning C4068: unknown pragma 'Rf_warning'
 src\bd0.c(42): warning C4068: unknown pragma 'Rf_warning'
 src\bd0.c(42): warning C4068: unknown pragma 'Rf_warning'
 src\bd0.c(42): error C2124: divide or mod by zero
 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
 ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-d3kgh8kz\\rvlib_6ae0b3c702e9456c94dc497fe29412da\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-d3kgh8kz\\rvlib_6ae0b3c702e9456c94dc497fe29412da\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-62kmmddr\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\user\appdata\local\programs\python\python38\Include\rvlib' Check the logs for full command output.```
knaaptime commented 2 years ago

hi, thanks for raising this

the best way to install rvlib is through conda-forge. I'd recommend using the mambaforge distribution of anaconda, then do

conda install rvlib

(if you use the mambaforge distribution you can swap conda for mamba which is a faster package manager)

If you want to build from source, you need to use the mingw compiler, not VS

hengshan commented 2 years ago

Hi, I'd like to ask the same question: how to install rvlib in Windows using pip not conda?

I am using QGIS and Pysal, which needs to install rvlib. Unforunately, QGIS uses its own Python which does not support conda.

I tried to build from resource use mingw64, but no makefile was found.

I then tried to build using build_lib.py, but python automatically used MSVS rather than mingw64.

Anyone can help with this? Thanks

jcrichard commented 2 years ago

Try pip install git+https://github.com/QuantEcon/rvlib

hengshan commented 2 years ago

Thanks @jcrichard

it still has the error:

Running setup.py install for rvlib ... error error: subprocess-exited-with-error

× Running setup.py install for rvlib did not run successfully. │ exit code: 1 ╰─> [105 lines of output] running install C:\Users\user\AppData\Roaming\Python\Python39\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

...... cl : Command line warning D9002 : ignoring unknown option '-std=c99' ......

error command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> rvlib

jcrichard commented 2 years ago

Might be due to the python version. Try to install it on python 3.6 on a separated env, which is the version I use.

hengshan commented 2 years ago

thanks @jcrichard As I have to use this specific version of Python (3.9.5) that QGIS provided, I may have to figure out how to build rvlib wheel in Windows using MinGW64.. Does anyone know how did Christoph Gohlke sucessfully build the wheel of pysal?

knaaptime commented 2 years ago

I'm not sure how he did it, but I'm a pysal dev, so I'll offer what help I can. It's probably not too difficult to build a wheel for the pysal metapackage, because as of version 2, the pysal package itself doesnt really contain any source code, just a set of dependencies for each of its specialized analytical libraries (what we call subpackages in pysal). Where you'll run into trouble is when you go to install Gholke's wheel, you likely wont be able to install the pysal segregation package which depends on rvlib.

the issue you're getting here:

......
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
......

happens because the installer is trying to compile rvlib's C modules using the visualstudio compiler. (as you can see, the error is coming from VS):

error command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe' failed with exit code 2

Instead, you need to make sure your system is setup properly to use Mingw. Resources like this might help. You need to make sure that mingw is in your PATH in whatever environment you're using to install rvlib. I don't have a windows machine handy, but I have been able to successfully build from source in a windows VM in the recent past (and our conda recipes on windows build successfully using the mingw toolchain)

knaaptime commented 2 years ago

another thing you could try is:

hengshan commented 2 years ago

thanks @knaaptime

I've tried to add either mingw64 bin or RTools40 mingw54 bin to PATH in OSGeo4W console, but it didn't work. When I pip install rvlib, it always uses MSVC. This happened when it tried to building 'rvlib._rmath_ffi' extension. It is wierd, as the path in OSGeo4W not even has the MSVC folder.

007vasy commented 1 year ago

63.3 Running setup.py install for rvlib: started

12 224.2 Running setup.py install for rvlib: still running...

12 270.1 Running setup.py install for rvlib: finished with status 'done'

12 270.1 DEPRECATION: rvlib was installed using the legacy 'setup.py install' method, because a wheel could not be built for it. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

I got this after finally installed rvlib by pinning it to the github commit: pip install git+https://github.com/QuantEcon/rvlib.git@6a0b896fdebd86d67bf307f44f59fc3493dcea34