Skip to main content
Solved

How can I properly use an anaconda python environment in PythonCaller?


Forum|alt.badge.img+2

I am trying to implement some python code that uses geopandas library, which I have installed in a local python environment on anaconda. I have made a few attempts to run it directly from PythonCaller transformer with no sucess: 

  • On fme desktop tools, I configured the fme python interpreter to get the .dll from the environment.
  • I also set the PYTHONHOME to the folder of the environment.

However, those configuration didn't work and I kept getting the error: No module named: "geopandas".

 

So, I also included this lines at the beginning of the code in PythonCaller:

import sys
sys.path.append(r"C:\Users\[username]\anaconda3\envs\[environment-name]\Lib\site-packages")

After that, I get a new error:

Python Exception <ModuleNotFoundError>: No module named 'pyproj._network'

 

I check on the "site-packages" folder and I have the pyproj package installed, so I don't know what could be causing this error,  in my anaconda environment the code runs without errors. 

 

Do you know what could be causing it?

Best answer by juandiegoboh

david_r wrote:

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.

View original
Did this help you find an answer to your question?

3 replies

david_r
Evangelist
  • June 8, 2022

Forum|alt.badge.img+2
  • Author
  • Best Answer
  • June 8, 2022
david_r wrote:

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.


mattwilkie
Supporter
Forum|alt.badge.img+11
  • Supporter
  • October 3, 2022
juandiegoboh wrote:

Hi David, thanks for sharing it, I've already read it. I did what people suggest in that post, unfortunately, my script still doesn't run correctly, I think it's due to a compatibility issue between the python of the anaconda install and FME.

 

But I have made it work, I have to recreate the libraries I have in my environment (ie leave out that env in my case) in the local fme python libraries installation (C:\\Users\\[username]\\Documents\\FME\\Plugins\\Python), which is not that easy as Geopandas has some problems in its dependencies when installing it using pip, then I updated to the latest version of FME (2022) and still had to change the python interpreter to use the version 3.9+, after that I successfully run the python script using geopandas.

Maybe edit your reply so the solution isn't hidden behind the [expand post] link. The first couple of times I read this thread while looking for help I missed the important part.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings