Unable to install directaccess package in FME environment
Closed this issue · 5 comments
Hi,
FME has a PythonCaller module for Python integration. I try to install directaccess package in FME environment through the following command:
fme.exe python -m pip install directaccess
I get the following error messages:
Collecting directaccess
Using cached https://files.pythonhosted.org/packages/c7/b2/3bb51148af50f4aeda5ced745224317357cbaa9ea11cb3ea0995eea69a69/directaccess-1.4.0-py2.py3-none-any.whl
Collecting unicodecsv==0.14.1 (from directaccess)
Using cached https://files.pythonhosted.org/packages/6f/a4/691ab63b17505a26096608cc309960b5a6bdf39e4ba1a793d5f9b1a53270/unicodecsv-0.14.1.tar.gz
Error [WinError 2] The system cannot find the file specified while executing command python setup.py egg_info
Could not install packages due to an EnvironmentError: [WinError 2] The system cannot find the file specified
It appears to have trouble with the "python setup.py egg_info" command. The FME installation is 2019 version on Windows 10.
Need some help to resolve this issue.
Thanks in advance.
Hi @kiauho, thanks for the question and that's a really cool use case!
I've just run through this successfully in FME Desktop 2019.2. My preferred Python interpreter is set to Python 3.7+ in the Translation options. My system has multiple versions of FME Desktop so this is the command I ran:
& "C:\Program Files\FME2019\fme.exe" python -m pip install directaccess --target C:\Users\<your.user>\Documents\FME\Plugins\Python\python37
Are you providing the --target flag? This Safe Software doc might be helpful if you haven't already seen it.
Your use case was interesting to me so I put together a basic PythonCreator using this module
import fme
import fmeobjects
from directaccess import DirectAccessV2
class EnverusFeatureCreator(object):
def __init__(self):
self.dataset = fme.macroValues['DATASET']
self.query = fme.macroValues['QUERY']
self.client_id = fme.macroValues['CLIENT_ID']
self.client_secret = fme.macroValues['CLIENT_SECRET']
self.api_key = fme.macroValues['API_KEY']
self.client = DirectAccessV2(self.client_id, self.client_secret, self.api_key)
self.log = fmeobjects.FMELogFile()
self.log.logMessageString(self.dataset)
def input(self, feature):
for row in self.client.query(self.dataset, **{x.split('=')[0]: x.split('=')[1] for x in self.query.split(';')}):
f = fmeobjects.FMEFeature()
f.setCoordSys('EPSG:4326')
if row['SurfaceLongitudeWGS84'] and row['SurfaceLatitudeWGS84']:
f.addCoordinate(row['SurfaceLongitudeWGS84'], row['SurfaceLatitudeWGS84'])
for k, v in row.items():
f.setAttribute(k, v)
self.pyoutput(f)
def close(self):
pass
I created five published parameters (DATASET, QUERY, CLIENT_ID, CLIENT_SECRET, API_KEY). DATASET matches the exact name of the dataset endpoint (in this case, permits), QUERY is a semi-colon separated string of query params (pagesize=100000;deleteddate=null) and the other three are your API credentials.
This is specific to permits, with the geometry field populated using that dataset's SurfaceLongitudeWGS84 and SurfaceLatitudeWGS84 fields. It's probably easy to make this a bit more configurable.
Hi wchatx,
Thanks for the prompt response and the FME sample code for PythonCreator. I am new to FME. It'll be very helpful, but first I need to overcome the directaccess installation.
My target location is different from yours. It is pointing to One Drive and the python37 is empty. The command is stuck in exactly place as before after using the command you suggested:
Collecting unicodecsv==0.14.1 (from directaccess)
Using cached https://files.pythonhosted.org/packages/6f/a4/691ab63b17505a26096608cc309960b5a6bdf39e4ba1a793d5f9b1a53270/unicodecsv-0.14.1.tar.gz
Error [WinError 2] The system cannot find the file specified while executing command python setup.py egg_info
Could not install packages due to an EnvironmentError: [WinError 2] The system cannot find the file specified
Any new thoughts?
Thanks in advance.
Kiauho
@kiauho try removing the \python37, I should not have included that. This module is usable in Python versions 2.7 and all of 3.x, hence Safe says your target should be C:\Users\<user>\Documents\FME\Plugins\Python
in their docs (modified for your unique situation).
I'm surprised to hear that your target deviates from what Safe specifies and that it's on a network-synced directory. That very well could be the source of your problem and I don't think I'll have much to offer there.
You can also try these older instructions using ez_setup.
Please follow up with your progress! I recall having installed modules into FME's python in a more traditional way previously and can try stepping through that if all else fails.