Hi, Im trying to run elementary with subprocess.ru...
# ask-elementary-ai
t
Hi, Im trying to run elementary with subprocess.run([]) within my dbt-snowflake project after installed elementary data(version 0.16.1). and gets this error: Encountered exception during execution: Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 2169, in orchestrate_task_run result = await call.aresult() ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 327, in aresult return await asyncio.wrap_future(self.future) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 352, in _run_sync result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/prefect/flows/data-dbt-prefect-develop/jobs/dbt_snowflake/dbt_daily_send_elementary_report_to_s3.py", line 18, in send_elementary_report_to_s3 result = subprocess.run([ ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/subprocess.py", line 1026, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.11/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'edr' 061930 PM send_elementary_report_to_s3-0 prefect.task_runs Error Finished in state Failed("Task run encountered an exception FileNotFoundError: [Errno 2] No such file or directory: 'edr'") Any idea how to fix?
k
A message from kapa.ai
The error you're encountering is because the system cannot find the
edr
command in your environment. This is a common issue when trying to run Elementary Data's CLI commands through subprocess. ## Why this happens The
FileNotFoundError: [Errno 2] No such file or directory: 'edr'
error occurs because: 1. The
edr
command isn't in your system's PATH 2. Elementary Data might not be properly installed in the environment where your subprocess is running ## How to fix it Based on similar issues from the Elementary community, here are some solutions: ### 1. Use the full path to the edr executable Instead of just using
'edr'
in your subprocess command, try using the full path to the edr executable:
Copy code
python # Find where edr is installed import shutil edr_path = shutil.which('edr') # Then use the full path in your subprocess result = subprocess.run([edr_path, 'monitor', 'send-report', ...])
### 2. Make sure Elementary is installed in the correct environment Several users have reported similar issues when Elementary wasn't properly installed in their environment:
Copy code
python # Install Elementary in your environment first subprocess.run(['pip', 'install', 'elementary-data[snowflake]'])
### 3. For Airflow/Prefect environments, use a virtual environment approach As seen in the community discussions, many users solved this by properly setting up a virtual environment:
Copy code
python # Example approach for running in a specific directory with environment setup subprocess.run([     'bash', '-c',      'cd /path/to/your/project && source /path/to/venv/bin/activate && edr monitor send-report ...' ])
### 4. Check if dbt is properly installed Elementary requires dbt to be installed and accessible. Make sure dbt is installed in the same environment where you're running the subprocess command [Slack forum user question](https://slack.com/archives/C02CTC89LAX/p1674765605663069). ## Additional troubleshooting If you're still facing issues, you might want to: 1. Verify Elementary is installed:
pip list | grep elementary
2. Check if the edr command is available:
which edr
3. Try running a simple edr command directly in your terminal to confirm it works outside of subprocess This is a common issue in the Elementary community, especially when running in containerized environments or automation platforms like Airflow and Prefect. I hope this helps resolve your issue! I'm here to help if you need further assistance with Elementary Data. I'm here to help if you need further assistance with Elementary Data.
t
Several users have reported similar issues when Elementary wasn't properly installed in their environment: About that. im using poetry to install my packages in my venv. maybe its related to that? maybe i need to change my dockerfile? right know
which edr
not works