Import yfinance in Python Script

Hi,

When calling yfinance using Python Scirpt Node, the following error occurs. Is there any way to solve this? Or can’t yfinance be called?

Executing the Python script failed: Error while obtaining a new communication channel

Other Python sources and other library calls (ex. pykrx) are performed normally.
Really simply, an error occurs even if you execute only one source line as shown below.
import yfinance

Any help from you would be greatly appreciated

Thanks,
Lee

Hi,

Here is the full code of what I did.

import pandas as pd
import yfinance as yf
import datetime
import knime.scripting.io as knio

sp500 = yf.download(“^GSPC”, start=“1980-01-01”)

sp500.reset_index(inplace=True)
sp500.rename(columns={‘index’: ‘Date’}, inplace=True)

knio.output_tables[0] = knio.Table.from_pandas(sp500)

Hi @bjlee3075,

I just tried your script in KNIME 4.7 and it works perfectly for me. It seems like there is something wrong with your conda environment. Can you check if you can use python and the yfinance package from an interactive Python session inside your conda environment?
I created an environment containing the yfinance package with the following command:

$ conda create --name tmp_yfinance_in_knime -c knime -c conda-forge knime-python-scripting=4.7 python=3.9 yfinance
3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.