ninia / jep

Embed Python in Java
Other
1.33k stars 151 forks source link

Cannot install JEP to a new computer #437

Open Daniel-Alievsky opened 2 years ago

Daniel-Alievsky commented 2 years ago

I try to install JEP to new computer, and I see an error message:

... copying src/main/resources/jep/classlist_10.txt to build/java/jep copying src/main/resources/jep/classlist_11.txt to build/java/jep "C:\Program Files\Java\jdk-19\bin\jar" -cf build/java/jep-4.1.0-sources.jar -C build/java/jep.src/main/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cfe build/java/jep-4.1.0.jar jep.Run -C build/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cf build/java/jep-4.1.0-test-sources.jar -C build/java/jep.test.src/test/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cfe build/java/jep-4.1.0-test.jar test.jep.Test -C build/java/test jep running build_py creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\console.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\java_import_hook.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\jdbc.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\redirect_streams.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\shared_modules_hook.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\version.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep__init__.py -> build\lib.win-amd64-cpython-311\jep running build_ext building 'jep' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [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. ╰─> jep note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

I've installed Python 3.11, Microsoft Visual Studio 2022, but it does not help. What can be a reason?

ndjensen commented 2 years ago

When you installed Visual Studio, did it prompt you with some checkboxes on what features to install? Generally speaking you need the Visual C++ Build Tools. It looks like you can follow the link in the error message to download those.

Daniel-Alievsky commented 2 years ago

The first thing that I've done was installing Microsoft C++ Build Tools, as it is written in the error message. Did you test JEP installation on Windows 11?

It seems that it is not too good idea to require compiler on Windows platform just to install JEP. Maybe it would be better to prepare precompiled version of all necessary DLL? For comparison, OpenCV library is distributed in compiled version for all popular platforms.

bsteffensmeier commented 2 years ago

The only Windows system where Jep is routinely tested is AppVeyor, I am not entirely sure which version of Windows AppVeyor is using but it is my understanding that Windows is generally compatible across versions so I would expect it to work equally well in Windows 11. I do not have much experience building in Windows but we are able to build on the AppVeyor system without any jep-specific modifications so all I can recommend is trying to setup a similar environment on your system.

We do not have the resources to distribute compiled versions of jep.

Daniel-Alievsky commented 2 years ago

I've tried to install Python + JEP again. Results are the same. Microsoft Build Tools and Visual Studio are installed: see attached picture. Below is the detailed log. What should I do now to install JEP?

Collecting jep Using cached jep-4.1.0.tar.gz (3.0 MB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Installing collected packages: jep DEPRECATION: jep is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 Running setup.py install for jep: started Running setup.py install for jep: finished with status 'error' error: subprocess-exited-with-error

Running setup.py install for jep did not run successfully. exit code: 1

[90 lines of output] numpy include found at C:\Users\Daniel\AppData\Roaming\Python\Python311\site-packages\numpy\core\include running install C:\Program Files\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running setup_java Using JAVA_HOME: C:\Program Files\Java\jdk-19 running build_java "C:\Program Files\Java\jdk-19\bin\javac" -deprecation -d build\java -h build\include -classpath src src\main\java\jep\AbstractNDArray.java src\main\java\jep\ClassEnquirer.java src\main\java\jep\ClassList.java src\main\java\jep\DirectNDArray.java src\main\java\jep\Interpreter.java src\main\java\jep\Jep.java src\main\java\jep\JepAccess.java src\main\java\jep\JepConfig.java src\main\java\jep\JepException.java src\main\java\jep\LibraryLocator.java src\main\java\jep\MainInterpreter.java src\main\java\jep\NamingConventionClassEnquirer.java src\main\java\jep\NDArray.java src\main\java\jep\Proxy.java src\main\java\jep\PyConfig.java src\main\java\jep\Run.java src\main\java\jep\SharedInterpreter.java src\main\java\jep\SubInterpreter.java src\main\java\jep\python\InvocationHandler.java src\main\java\jep\python\MemoryManager.java src\main\java\jep\python\PyCallable.java src\main\java\jep\python\PyObject.java src\main\java\jep\python\PyPointer.java "C:\Program Files\Java\jdk-19\bin\javac" -deprecation -d build\java\test -classpath build\java;src src\test\java\jep\test\Test.java src\test\java\jep\test\TestCloseWithThreads.java src\test\java\jep\test\TestCompiledScript.java src\test\java\jep\test\TestDefaultMethods.java src\test\java\jep\test\TestExceptionCause.java src\test\java\jep\test\TestExec.java src\test\java\jep\test\TestGetByteArray.java src\test\java\jep\test\TestGetCollectionBoxing.java src\test\java\jep\test\TestGetJPyObject.java src\test\java\jep\test\TestGetTempValue.java src\test\java\jep\test\TestGetWithClass.java src\test\java\jep\test\TestInvoke.java src\test\java\jep\test\TestIteratorable.java src\test\java\jep\test\TestOverload.java src\test\java\jep\test\TestPreInitVariables.java src\test\java\jep\test\TestPyJObject.java src\test\java\jep\test\TestPyJType.java src\test\java\jep\test\TestRedirectStreams.java src\test\java\jep\test\TestSharedArgv.java src\test\java\jep\test\TestSharedInterpreter.java src\test\java\jep\test\TestSharedModules.java src\test\java\jep\test\TestSharedModulesThreads.java src\test\java\jep\test\closeable\TestAutoCloseable.java src\test\java\jep\test\numpy\TestNumpy.java src\test\java\jep\test\numpy\TestNumpyArrayToString.java src\test\java\jep\test\numpy\TestNumpyProdShared.java src\test\java\jep\test\numpy\example\TestNumpyGILFreeze.java src\test\java\jep\test\numpy\example\TestNumpyMemoryLeak.java src\test\java\jep\test\numpy\example\TestNumpyProdLost.java src\test\java\jep\test\numpy\example\TestScipyFreeze.java src\test\java\jep\test\synchronization\TestCrossLangSync.java src\test\java\jep\test\types\TestFieldTypes.java src\test\java\jep\test\types\TestMethodTypes.java src\test\java\jep\test\types\TestStaticFieldTypes.java src\test\java\jep\test\types\TestStaticMethodTypes.java copying src\main\java\jep\AbstractNDArray.java to build\java\jep.src\main\java\jep\AbstractNDArray.java copying src\main\java\jep\ClassEnquirer.java to build\java\jep.src\main\java\jep\ClassEnquirer.java copying src\main\java\jep\ClassList.java to build\java\jep.src\main\java\jep\ClassList.java copying src\main\java\jep\DirectNDArray.java to build\java\jep.src\main\java\jep\DirectNDArray.java copying src\main\java\jep\Interpreter.java to build\java\jep.src\main\java\jep\Interpreter.java copying src\main\java\jep\Jep.java to build\java\jep.src\main\java\jep\Jep.java copying src\main\java\jep\JepAccess.java to build\java\jep.src\main\java\jep\JepAccess.java copying src\main\java\jep\JepConfig.java to build\java\jep.src\main\java\jep\JepConfig.java copying src\main\java\jep\JepException.java to build\java\jep.src\main\java\jep\JepException.java copying src\main\java\jep\LibraryLocator.java to build\java\jep.src\main\java\jep\LibraryLocator.java copying src\main\java\jep\MainInterpreter.java to build\java\jep.src\main\java\jep\MainInterpreter.java copying src\main\java\jep\NamingConventionClassEnquirer.java to build\java\jep.src\main\java\jep\NamingConventionClassEnquirer.java copying src\main\java\jep\NDArray.java to build\java\jep.src\main\java\jep\NDArray.java copying src\main\java\jep\Proxy.java to build\java\jep.src\main\java\jep\Proxy.java copying src\main\java\jep\PyConfig.java to build\java\jep.src\main\java\jep\PyConfig.java copying src\main\java\jep\Run.java to build\java\jep.src\main\java\jep\Run.java copying src\main\java\jep\SharedInterpreter.java to build\java\jep.src\main\java\jep\SharedInterpreter.java copying src\main\java\jep\SubInterpreter.java to build\java\jep.src\main\java\jep\SubInterpreter.java copying src\main\java\jep\python\InvocationHandler.java to build\java\jep.src\main\java\jep\python\InvocationHandler.java copying src\main\java\jep\python\MemoryManager.java to build\java\jep.src\main\java\jep\python\MemoryManager.java copying src\main\java\jep\python\PyCallable.java to build\java\jep.src\main\java\jep\python\PyCallable.java copying src\main\java\jep\python\PyObject.java to build\java\jep.src\main\java\jep\python\PyObject.java copying src\main\java\jep\python\PyPointer.java to build\java\jep.src\main\java\jep\python\PyPointer.java copying src\test\java\jep\test\Test.java to build\java\jep.test.src\test\java\jep\test\Test.java copying src\test\java\jep\test\TestCloseWithThreads.java to build\java\jep.test.src\test\java\jep\test\TestCloseWithThreads.java copying src\test\java\jep\test\TestCompiledScript.java to build\java\jep.test.src\test\java\jep\test\TestCompiledScript.java copying src\test\java\jep\test\TestDefaultMethods.java to build\java\jep.test.src\test\java\jep\test\TestDefaultMethods.java copying src\test\java\jep\test\TestExceptionCause.java to build\java\jep.test.src\test\java\jep\test\TestExceptionCause.java copying src\test\java\jep\test\TestExec.java to build\java\jep.test.src\test\java\jep\test\TestExec.java copying src\test\java\jep\test\TestGetByteArray.java to build\java\jep.test.src\test\java\jep\test\TestGetByteArray.java copying src\test\java\jep\test\TestGetCollectionBoxing.java to build\java\jep.test.src\test\java\jep\test\TestGetCollectionBoxing.java copying src\test\java\jep\test\TestGetJPyObject.java to build\java\jep.test.src\test\java\jep\test\TestGetJPyObject.java copying src\test\java\jep\test\TestGetTempValue.java to build\java\jep.test.src\test\java\jep\test\TestGetTempValue.java copying src\test\java\jep\test\TestGetWithClass.java to build\java\jep.test.src\test\java\jep\test\TestGetWithClass.java copying src\test\java\jep\test\TestInvoke.java to build\java\jep.test.src\test\java\jep\test\TestInvoke.java copying src\test\java\jep\test\TestIteratorable.java to build\java\jep.test.src\test\java\jep\test\TestIteratorable.java copying src\test\java\jep\test\TestOverload.java to build\java\jep.test.src\test\java\jep\test\TestOverload.java copying src\test\java\jep\test\TestPreInitVariables.java to build\java\jep.test.src\test\java\jep\test\TestPreInitVariables.java copying src\test\java\jep\test\TestPyJObject.java to build\java\jep.test.src\test\java\jep\test\TestPyJObject.java copying src\test\java\jep\test\TestPyJType.java to build\java\jep.test.src\test\java\jep\test\TestPyJType.java copying src\test\java\jep\test\TestRedirectStreams.java to build\java\jep.test.src\test\java\jep\test\TestRedirectStreams.java copying src\test\java\jep\test\TestSharedArgv.java to build\java\jep.test.src\test\java\jep\test\TestSharedArgv.java copying src\test\java\jep\test\TestSharedInterpreter.java to build\java\jep.test.src\test\java\jep\test\TestSharedInterpreter.java copying src\test\java\jep\test\TestSharedModules.java to build\java\jep.test.src\test\java\jep\test\TestSharedModules.java copying src\test\java\jep\test\TestSharedModulesThreads.java to build\java\jep.test.src\test\java\jep\test\TestSharedModulesThreads.java copying src\test\java\jep\test\closeable\TestAutoCloseable.java to build\java\jep.test.src\test\java\jep\test\closeable\TestAutoCloseable.java copying src\test\java\jep\test\numpy\TestNumpy.java to build\java\jep.test.src\test\java\jep\test\numpy\TestNumpy.java copying src\test\java\jep\test\numpy\TestNumpyArrayToString.java to build\java\jep.test.src\test\java\jep\test\numpy\TestNumpyArrayToString.java copying src\test\java\jep\test\numpy\TestNumpyProdShared.java to build\java\jep.test.src\test\java\jep\test\numpy\TestNumpyProdShared.java copying src\test\java\jep\test\numpy\example\TestNumpyGILFreeze.java to build\java\jep.test.src\test\java\jep\test\numpy\example\TestNumpyGILFreeze.java copying src\test\java\jep\test\numpy\example\TestNumpyMemoryLeak.java to build\java\jep.test.src\test\java\jep\test\numpy\example\TestNumpyMemoryLeak.java copying src\test\java\jep\test\numpy\example\TestNumpyProdLost.java to build\java\jep.test.src\test\java\jep\test\numpy\example\TestNumpyProdLost.java copying src\test\java\jep\test\numpy\example\TestScipyFreeze.java to build\java\jep.test.src\test\java\jep\test\numpy\example\TestScipyFreeze.java copying src\test\java\jep\test\synchronization\TestCrossLangSync.java to build\java\jep.test.src\test\java\jep\test\synchronization\TestCrossLangSync.java copying src\test\java\jep\test\types\TestFieldTypes.java to build\java\jep.test.src\test\java\jep\test\types\TestFieldTypes.java copying src\test\java\jep\test\types\TestMethodTypes.java to build\java\jep.test.src\test\java\jep\test\types\TestMethodTypes.java copying src\test\java\jep\test\types\TestStaticFieldTypes.java to build\java\jep.test.src\test\java\jep\test\types\TestStaticFieldTypes.java copying src\test\java\jep\test\types\TestStaticMethodTypes.java to build\java\jep.test.src\test\java\jep\test\types\TestStaticMethodTypes.java running build_jar copying src/main/resources/jep/classlist_8.txt to build/java/jep copying src/main/resources/jep/classlist_9.txt to build/java/jep copying src/main/resources/jep/classlist_10.txt to build/java/jep copying src/main/resources/jep/classlist_11.txt to build/java/jep "C:\Program Files\Java\jdk-19\bin\jar" -cf build/java/jep-4.1.0-sources.jar -C build/java/jep.src/main/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cfe build/java/jep-4.1.0.jar jep.Run -C build/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cf build/java/jep-4.1.0-test-sources.jar -C build/java/jep.test.src/test/java jep "C:\Program Files\Java\jdk-19\bin\jar" -cfe build/java/jep-4.1.0-test.jar test.jep.Test -C build/java/test jep running build_py creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\console.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\java_import_hook.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\jdbc.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\redirect_streams.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\shared_modules_hook.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep\version.py -> build\lib.win-amd64-cpython-311\jep copying src\main\python\jep__init__.py -> build\lib.win-amd64-cpython-311\jep running build_ext building 'jep' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [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.

jep

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

visualstudio

Daniel-Alievsky commented 2 years ago

At the same time, a copy of Python with installed JEP, built on another computer, works well. But it is obviously not a correct solution.

ndjensen commented 2 years ago

Did you install Visual Studio and the build tools to their default install location or did you change it? That sadly could make a difference as I think when it goes looking for things it might check some default directories. Also check the PATH environment variable and see if it matches between the two machines. I think one of the fallbacks when searching for the executables is to check PATH. You can also debug into the code that does some of the lookups, it is over here: https://github.com/pypa/setuptools/blob/v65.5.0/setuptools/_distutils/_msvccompiler.py Change the version tag to match whatever version of setuptools you have installed.

Daniel-Alievsky commented 2 years ago

I've installed all according default options. Here is my PATH variable: PATH=C:\Program Files\Python311\Scripts\;C:\Program Files\Python311\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\UltraEdit;C:\Program Files\WinRAR\;C:\Users\Daniel\AppData\Local\Microsoft\WindowsApps;

We would like to distribute JEP together with our main product, multi-language visual environment for development algorithms and other solution. For the first time, of course, we will focus in Windows. Could you offer some distribution package of JEP for Windows, which will be precompiled and will not depend on correct installation of Visual Studio? It may be very simple, just some ZIP or MSI file which will install necessary JEP libraries, oriented to using numpy. It seems to be not to very difficult.

Daniel-Alievsky commented 2 years ago

It seems that there was something strange with Visual Studio installer. After several attempts to reinstall it, C++ compiler was added, and "pip install jep" worked successfully.

But I've run into another problem. I installed Python for all users, so, it appeared in "C:\Program Files". So, I've set PYTHONHOME to Python's folder inside "C:\Program Files". Then I've installed numpy and JEP, They appeared in my user directory: C:\Users\Daniel\AppData\Local\Programs\Python\Python311 Result: your Java part was unable to find necessary DLL (UnsatisfiedLinkError)

Yes, I've resolved this and installed Python + JEP locally. But it seems there should be more simple algorithm for installing JEP on Python, at least for Windows platform... Are you sure that it is impossible to distribute precompiled version (compiled with Numpy) at least for most popular platforms like Windows and Linux?

ctrueden commented 1 year ago

@Daniel-Alievsky wrote:

It seems that it is not too good idea to require compiler on Windows platform just to install JEP. Maybe it would be better to prepare precompiled version of all necessary DLL? For comparison, OpenCV library is distributed in compiled version for all popular platforms.

@bsteffensmeier wrote:

We do not have the resources to distribute compiled versions of jep.

I think the best solution would be fix the conda-forge recipe to build and publish precompiled binaries for all platforms. The conda-forge infrastructure is already there; it likely needs only small adjustments to be fixed (@ndjensen @bsteffensmeier correct me if I am wrong). @Daniel-Alievsky If your team has the resources to fix it, it would be a nice way to give back to the community.

Daniel-Alievsky commented 1 year ago

If your team has the resources to fix it, it would be a nice way to give back to the community.

Unfortunately no, sorry.

icemachined commented 1 year ago

I have created an open source project which build and publish jep binaries to maven. See https://github.com/icemachined/jep-distro . You can use it without pip install, there is an example project https://github.com/icemachined/jep-distro-example