如何在heroku上运行包含php的库的python脚本?

时间:2023-01-12 19:48:49

I am all new to Heroku and I wanted to call the python script which contains libraries like numpy and opencv. They execute on localhost from PHP when I call them using shell_exec() or exec() function. But in Heroku, only simple python script which does not contain any library imported are executing. Whenever the libraries are imported it fails. I have set the buildpack as PHP and python.

我是Heroku的新手,我想调用包含numpy和opencv等库的python脚本。当我使用shell_exec()或exec()函数调用它们时,它们在PHP上执行localhost。但是在Heroku中,只有不包含任何导入库的简单python脚本正在执行。每当导入库时它都会失败。我已将buildpack设置为PHP和python。

I want that python script to be executed from PHP please help me with it!. I have searched a lot but methods are not working. They are working fine on local host.

我希望从PHP执行python脚本请帮助我!我搜索了很多,但方法不起作用。他们在当地主机上工作正常。

In alternative if there is a way in which I can host the application apart from heroku where both the php and python script can be executed let me know about that also.

在另一种选择中,如果有一种方法可以让我可以托管应用程序,除了heroku,php和python脚本都可以执行,让我也知道。

1 个解决方案

#1


0  

Create requirements.txt by using cmd pip freeze > requirements.txt in the desired folder it will define all the required libraries or do it manually in the following format:-

使用所需文件夹中的cmd pip freeze> requirements.txt创建requirements.txt,它将定义所有必需的库,或者按以下格式手动执行: -

Flask==0.9-devdev-20120114
Jinja2==2.6
Werkzeug==0.8.2
wsgiref==0.1.2

And then deploy your app.

然后部署您的应用程序。

Let me know if it worked.

如果有效,请告诉我。

#1


0  

Create requirements.txt by using cmd pip freeze > requirements.txt in the desired folder it will define all the required libraries or do it manually in the following format:-

使用所需文件夹中的cmd pip freeze> requirements.txt创建requirements.txt,它将定义所有必需的库,或者按以下格式手动执行: -

Flask==0.9-devdev-20120114
Jinja2==2.6
Werkzeug==0.8.2
wsgiref==0.1.2

And then deploy your app.

然后部署您的应用程序。

Let me know if it worked.

如果有效,请告诉我。