Giter VIP home page Giter VIP logo

Comments (5)

Stewori avatar Stewori commented on June 23, 2024 1

I think you have to examine the launch process of processing. To clarify: I hadn't had a look at it at all.
Is it launched by a shell script or bat file (on WIndows) or something? Or by an executable? How would you make any other ordinary Java library available to it?
What you can also try: Search the whole repo for the text 'jython.jar' or 'mode/Jython.jar' or 'mode'. This might point you to the launcher. Or search for '-cp'. Is there something in the doc explaining how to make Java libraries available?

When launching from command line via java ... the -cp=... flag configures the classpath. See https://github.com/Stewori/JyNI#running-jyni

That said, keep in mind that JyNI is highly experimental. Using unsupported API crashes the JVM. Attempting to import an extension that doesn't work yet crashes the JVM. Be prepared for frequent full JVM crashes. Some NumPy core functionality works but it is not very exhaustive.

from jyni.

Stewori avatar Stewori commented on June 23, 2024 1

You can try to insert additional classpath here and in processing-py.bat as well if you need it on WIndows. However, the setup is fairly complex and maybe it somehow overides the classpath configured there. It might require some serious effort to sort things out.

from jyni.

solub avatar solub commented on June 23, 2024 1

Thank you so much for the reply.

All the libraries are available in the libraries sub-folder of Processing. Each library folder contains another folder called 'library' where the jar file is usually placed.

Processing -> libraries -> [LibraryName] -> library -> [LibraryName].jar

I already tried to create a JyNI folder inside libraries and put the jar file with the dll within a library sub-folder, following the same order. JyNI is then recognized as a library and I can import it in a Processing sketch however it is impossible to import numpy (1.13.3).

add_library('JyNI')

import sys
sys.path.append('C:\Python27\Lib\site-packages')

import numpy as np
processing.app.SketchException: import * does not work in this environment.
	at jycessing.mode.run.SketchRunner.convertPythonSketchError(SketchRunner.java:234)
	at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:119)
	at java.lang.Thread.run(Thread.java:748)

When running the same sketch but replacing numpy 1.13.3 in site-packages by version 1.16.4, the error message is different:

processing.app.SketchException: ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using C:\Users\solub\Documents\Processing\modes\PythonMode\mode\bin\jython.exe),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: DLL load failed: %1 n?est pas une application Win32 valide

	at jycessing.mode.run.SketchRunner.convertPythonSketchError(SketchRunner.java:234)
	at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:119)
	at java.lang.Thread.run(Thread.java:748)

from jyni.

Stewori avatar Stewori commented on June 23, 2024 1

You may want to have a look at https://github.com/Stewori/JyNI/blob/master/JyNI-Java/src/JyNI/JyNI.java#L114 to better understand the logic. Make sure to observe System.err output for clues. Check if processing hides this output (maybe it overrides System.err) and how it can be accessed in that case.

from jyni.

Stewori avatar Stewori commented on June 23, 2024

Don't try NumPy > 1.13 atm. It won't work, see #22. Stick to 13.3 specifically.
Then before you attempt to import NumPy, which has a lot of potential failure possibilities, try to import datetime and confirm that datetime.__doc__ reads "Fast implementation of the datetime type.". Much like in JyNIDatetimeTest. In that code, the line sys.path.insert(0, '/usr/lib/python2.7/lib-dynload') shouldn't be required any more as of alpha 5: https://github.com/Stewori/JyNI/releases/tag/v2.7-alpha.5 as datetime is builtin now. (It may be required for other extensions though).

If datetime.__doc__ is other than "Fast implementation of the datetime type.", Jython's original datetime was loaded, meaning Jython did not recognize JyNI for some reoson. This can likely be caused by the clash of two environments being too smart (processing vs JyNI). E.g. JyNI actively searches the classpath for its native libs although they would usually reside on the library path rather than on classpath. Maybe processing loads the jars from the libraries folder using a custom class loader and not by putting them on the classpath. That might prevent JyNI from finding its native libs. You can try to put JyNI's native libs on the library path rather than on the classpath (I'm not sure if that works on Windows). You can specify the library path via the JVM flag -Djava.library.path.

from jyni.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.