“module 'socket.http' not found:” -- 在 iMac 上的 Lua 中。

当我在终端中运行我的代码时,我收到以下错误/信息:

module 'socket.http' not found:
    no field package.preload['socket.http']
    no file '/usr/local/share/lua/5.2/socket/http.lua'
    no file '/usr/local/share/lua/5.2/socket/http/init.lua'
    no file '/usr/local/lib/lua/5.2/socket/http.lua'
    no file '/usr/local/lib/lua/5.2/socket/http/init.lua'
    no file './socket/http.lua'
    no file '/usr/local/lib/lua/5.2/socket/http.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './socket/http.so'
    no file '/usr/local/lib/lua/5.2/socket.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './socket.so'

一些来源让我研究 LuaSocket,但我仍然不知道该怎么做或如何安装它。

点赞
用户1190388
用户1190388

有几个地方可以安装LuaSocket的指南。其中一些如下所示:

我首选的方法是安装LuaRocks,然后在终端中使用以下命令:

luarocks install luasocket
2013-05-11 00:03:48
用户2079029
用户2079029

一些需要注意的事项。在配置luarocks时,您可能需要指向Lua安装目录,例如: ./configure --with-lua=/opt/lua53/

还有类似的选项: --with-lua-bin --with-lua-include 您可以使用任何一个,但请确保您所提到的目录中存在所需的目录结构!

2017-02-13 07:19:47