wordpress - 在服务器上找不到 Python 脚本
问题描述
我正在开发一个嵌入 Python 脚本的 Wordpress 插件。我已将 Python 脚本上传到我的服务器,起初我在要运行我的脚本的网页上收到一条错误消息,说“权限被拒绝”(我已将 stderr 重定向到 stdout 以使我能够看到错误消息)。当我添加执行权限时,我会收到一条“未找到”消息(通过 Filezilla 完成)。
我可以看到脚本在服务器上的正确文件夹中,并且显然是在权限错误时发现的。如何让我的插件找到 Python 文件?
这是插件中的相关PHP函数:
function embed_python( $attributes )
{
$data = shortcode_atts(
[
'file' => 'hello.py'
],
$attributes
);
$handle = popen( __DIR__ . '/' . $data['file'] . ' 2>&1', 'r' );
$read = '';
while ( ! feof( $handle ) )
{
$read .= fread( $handle, 2096 );
}
pclose( $handle );
return $read;
}
解决方案
原来它就像我使用的服务器(Loopia)一样简单,需要某个文件夹中的 Python 脚本才能找到/运行它,以及更改了几个设置,请参阅这个瑞典页面:https://support。 loopia.se/wiki/python/。
推荐阅读
- python - 需要有关此错误的帮助:只能将列表(而不是“str”)连接到列表
- kotlin-flow - kotlin flow 没有从不同的函数发出值
- tensorflow - 限制CNN中不相关图像的概率百分比
- blazor - 如何在 Blazor 中编写自定义值更改事件处理程序?
- python - 如何正确地从文本中获取不会引发 InvalidSchema("No connection adapters were found for {!r}".format(url)) 错误的 URL?
- php - 如何在 Laravel 5.4 中验证多维数组并使用请求值作为参数?
- python - 将二叉树转换为路径
- mongodb - 对集合的子集执行 $lookup
- java - 具有属性 AND 值的 xml 反序列化
- angularjs - Angular(SPA) 前端和 Spring Boot 后端的 SAML 2.0 集成