Summer Sale! All accounts are 50% off this week.

johndoee's avatar

How can handle import python library in laravel

although laravel can get python simple script (example print ) , cannot run python import packages. how can call that i import these package python

# import the Binance client from python-binance module
from binance.client import Client
# import TA
from tradingview_ta import TA_Handler, Interval, Exchange

but warning

[{
	"resource": "/c:/Users/PC/Desktop/cryptobot/main.py",
	"owner": "_generated_diagnostic_collection_name_#2",
	"code": {
		"value": "reportMissingImports",
		"target": {
			"$mid": 1,
			"external": "https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules",
			"path": "/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md",
			"scheme": "https",
			"authority": "github.com",
			"fragment": "diagnostic-severity-rules"
		}
	},
	"severity": 4,
	"message": "Import \"tradingview_ta\" could not be resolved",
	"source": "Pylance",
	"startLineNumber": 3,
	"startColumn": 6,
	"endLineNumber": 3,
	"endColumn": 20
}]

How can import python package in laravel .

 public function index(){
      $command = escapeshellcmd("C:\Users\PC\AppData\Local\Programs\Python\Python310\python.exe C:\Users\PC\Desktop\cryptobot\python.py");
      $process = shell_exec($command); 
   
       return view('python',compact('process'));
        

     }

0 likes
2 replies
Tray2's avatar

What kind of python script do you want to run and what do you expect php to display?

If it's somthing more advanced I suggest porting it to php.

johndoee's avatar

@Tray2 how can porting , i need to import example pip install tradingview_ta --upgrade and pip install python-binance. i not know how to porting . here python script .

#!/c/Users/PC/AppData/Local/Programs/Python/Python310/python

print("Hello, World from Python! you can see me")

# import the Binance client from python-binance module
from binance.client import Client
# import TA
from tradingview_ta import TA_Handler, Interval, Exchange

# import required library for timing our DCA
from time import sleep
import pprint

# define your API key and secret
API_KEY = "7kGhpRbjVsnonEcI801sSuqGEd4qnvO3E4p4sPERKpPHbyLt3wvY4WLwwt1wrDTd"
API_SECRET = "YyvkwjA48E5xZIOjxUUt705Wp9UCplAydFNdDv9d3R4Mi3Z0pPusWl2NOFwjaZCz"

# define the client
client = Client(API_KEY, API_SECRET, testnet=True)

# #order book
tickers = client.get_orderbook_tickers()
pprint.pprint(tickers)

info = client.get_account()
pprint.pprint(info)

here controller

 public function index(){
      $command = escapeshellcmd("C:\Users\PC\AppData\Local\Programs\Python\Python310\python.exe C:\Users\PC\Desktop\cryptobot\python.py");
      $process = shell_exec($command); 
       //dd($process);
       return view('python',compact('process'));
        

     }
  

Please or to participate in this conversation.