Skip to main content

Hi all,

I am trying to use the module matplotlib inside FME itself so I can create histograms and store them on my hard drive.

I installed matplotlib in my standard Python 2.7 - 64 bit interpreter (the one that is used when you type 'python' in the command prompt) and I use this interpreter in pycharm (C:\\Python27\\python.exe) where everything works smoothly.

Now I would like to use this interpreter inside FME but I cannot get it working. I checked the internet thoroughly and tried already a lot. I didn't try to install matplotlib in the FME python interpreter since I use different versions of FME.

I tried using the following dlls:

C:\\Windows\\system32\\python27.dll (but this is 32-bit so it shouldn't work I guess...)

C:\\Windows\\SysWOW64\\python27.dll (but this generates an error)

In order to try to fix the first error, I checked if the correct paths are added to the environment variables (C:\\Python27;C:\\Python27\\Lib) which is the case.

I do not understand the second error.

Is there someone who encountered this problem and knows how to fix it?

 

For these tests, I used FME build 15250 (64bit version)

Thank you!

Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David


Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David

Hi david_r

Thanks for the fast reaction!

Adding the PYTHONHOME-variable did the trick! The Workspaces completes the task. At the end however, an error is thrown everytime the program runs.

 

All pythoncode is executed but since this model is created for a customer, I would like to get rid of the error. Do you have an idea how I can do this?


Hi david_r

Thanks for the fast reaction!

Adding the PYTHONHOME-variable did the trick! The Workspaces completes the task. At the end however, an error is thrown everytime the program runs.

 

All pythoncode is executed but since this model is created for a customer, I would like to get rid of the error. Do you have an idea how I can do this?

Good to hear PYTHONHOME helped. That might indicate that your PATH points to another Python installation before the one in C:\\python27.

Regarding the error I see that there is a fatal Python error shown in the log window, but it is virtually impossible to tell where the problem lies without analysing/debugging the Python code in question. It might, however, be related to your PATH again and different versions of the MSVC libraries. Maybe try the steps outlined here and see if it helps.


Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\Python27, see here for more info.

David

The pythoncode that is used is just some 'dummy' code in order to test the matplotlib functionality (see below - just a creator and pythoncaller).

I tried reinstalling the Visual C++ Redistributial but that didn't fix the issue. 

I am unfortunately not allowed to update windows to the last version. Therefore I cannot test if that would do the trick. I tried the same code in FME 2015.0, 2015.1 and 2016 and they all result in the same error.

Thanks for the help!

import fme
import fmeobjects

import matplotlib.pyplot as plt

# Template Function interface:
def processFeature(feature):

    x = y1, 2, 3, 4, 5]
    y = T10, 15, 3, 18, 7]
    nbBins = 5

    plt.hist(x, weights=y)
    plt.savefig('D:/histogram.png') 

The pythoncode that is used is just some 'dummy' code in order to test the matplotlib functionality (see below - just a creator and pythoncaller).

I tried reinstalling the Visual C++ Redistributial but that didn't fix the issue. 

I am unfortunately not allowed to update windows to the last version. Therefore I cannot test if that would do the trick. I tried the same code in FME 2015.0, 2015.1 and 2016 and they all result in the same error.

Thanks for the help!

import fme
import fmeobjects

import matplotlib.pyplot as plt

# Template Function interface:
def processFeature(feature):

    x = >1, 2, 3, 4, 5]
    y = f10, 15, 3, 18, 7]
    nbBins = 5

    plt.hist(x, weights=y)
    plt.savefig('D:/histogram.png') 

Reinstalling MSVC won't help in 99% of cases. You'll probably have to progressively remove folders from your PATH environment variable until it starts working, and then you'll have found your culprit. Unfortunately, problems with different versions on the MSVC is well known and not limited to FME. Lots to be found on this issue with Google...

For your script, the only thing I can suggest is to add

plt.close() 

At the end of processFeatures. Let us know if it makes a difference.


Hi

Did you look at this article on how to select the right dll?

Also consider setting the environment variable PYTHONHOME to c:\\Python27, see here for more info.

David

It did!

Everything works smoothly now.

Thank you very much David!


Reply