matplotlib4j icon indicating copy to clipboard operation
matplotlib4j copied to clipboard

does not work on windows running anaconda

Open omryoz opened this issue 4 years ago • 5 comments

Tried to execute the sample code on jvm running on windows with anaconda 4.8.2 installed using default configuration (python3)- failed. I've tried to configure py2 environment but executeSilently fails.

java.io.IOException: Cannot run program "bash": CreateProcess error=2, The system cannot find the file specified

omryoz avatar Mar 19 '20 14:03 omryoz

The error says it's missing bash. It may have caused the error that it runs with bash when pyenvConfig is chosen.

Indeed I haven't tested on Windows, but it might run when WSL (Windows Subsystem for Linux) is enabled, so could you try that? Anyways added the comment about which OS was tested: https://github.com/sh0nk/matplotlib4j/commit/ce978bcf2838a15447b6e2ab65814014a1a504e1

sh0nk avatar Jul 24 '20 16:07 sh0nk

This is really awesome!

As an update, I just tried on windows 10 pro 20H2 19042.985.

I made a test class

package Matplotlib;

import com.github.sh0nk.matplotlib4j.Plot;
import com.github.sh0nk.matplotlib4j.PythonExecutionException;
import java.io.IOException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tobid
 */
public class MatplotlibTest {

    public static void main(String[] args){
        Plot plt = Plot.create();
        plt.plot()
                .add(Arrays.asList(1.3, 2))
                .label("label")
                .linestyle("--");
        plt.xlabel("xlabel");
        plt.ylabel("ylabel");
        plt.text(0.5, 0.2, "text");
        plt.title("Title!");
        plt.legend();
        try {
            plt.show();
        } catch (IOException ex) {
            Logger.getLogger(MatplotlibTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch (PythonExecutionException ex) {
            Logger.getLogger(MatplotlibTest.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}

We are using ivy in our project. I installed the ivy dependency in our ivy.xml

            <dependency org="com.github.sh0nk" name="matplotlib4j" rev="0.5.0" />

matplotlib4j was downloaded fine. I just canceled the request for some mysterious authentication (something to do with ivy and github I don't understand).

On first run, the output told me to run python from cmd.exe to install python from windows store. I did this, the app store popped up and offered to install python 3.9. I did that, then ran "pip install matplotlib" in the cmd window, which went fine. Then I went back to netbeans and run the MatplotlibTest main method

The test plot popped right up.

2021-05-25_200848

This is really great, thank you for this excellent development!

tobidelbruck avatar May 25 '21 18:05 tobidelbruck

@tobidelbruck Thank you for your installation details. Since I am not a Windows user, that information must be very helpful for other Windows users! Please feedback again if you meet anything weird.

sh0nk avatar May 30 '21 07:05 sh0nk

How should we integrate anaconda environment to this library. The base python version of my Anaconda environment does not have matplotlib installed. How do I modify the pythonconfig object to use my Anaconda virtual enviornment?

NeerajanS avatar Mar 12 '22 03:03 NeerajanS

@NeerajanS Since this library depends on matplotlib entirely, it does not work without matplotlib. Is it possible to install matplotlib on your anaconda environment? https://matplotlib.org/stable/users/installing/index.html#conda-packages

sh0nk avatar Mar 15 '22 06:03 sh0nk