wrk how to install additional lua modules - macos

I am using mac OSX. I have Lua installed through brew and Luarocks. I have the lua sockets package installed too.
When I call local http = require("socket") from the terminal lua command line interface, the module loads fine.
However when I include local http = require("socket") in my wrk test scripts, I get errors not just for socket but for other modules too. It seems like its not using the Lua on my system.
Is there a way to install dependent modules for wrk?
package.searchpath( "socket", package.path ) returns /usr/local/share/lua/5.2/socket.lua
Here is the error for reference
scripts/get_call_setup.lua: scripts/get_call_setup.lua:1: module 'socket' not found:
no field package.preload['socket']
no file './socket.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/luajit-2.0.4/socket.lua'
no file '/usr/local/share/lua/5.1/socket.lua'
no file '/usr/local/share/lua/5.1/socket/init.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/lua/5.1/socket.lua'
no file '/Users/sak/go/src/personal/wrk/obj/share/lua/5.1/socket/init.lua'
no file './socket.so'
no file '/usr/local/lib/lua/5.1/socket.so'
no file '/Users/sak/go/src/personal/wrk/obj/lib/lua/5.1/socket.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
Running 3s test # https://ccx-courier-stage.adobe.io

Be sure Luarocks config correctly and luarocks install destination is in your path.
In terminal, run this below code to add the installed library to your path.
eval "$(luarocks path)"
Then run your code:
lua myscript.lua
Beside that, your package is installed for lua 5.2:
package.searchpath( "socket", package.path ) returns /usr/local/share/lua/5.2/socket.lua
But you run your code with lua 5.1:
no file '/usr/local/share/lua/5.1/socket.lua'
Install socket for lua 5.1 then run your code or run your script with lua 5.2 if all library is install for lua 5.2.
lua5.2 myscript.lua

Related

(LUA) Failed to install winapi

im have problem with install winapi lua.
OS : Win 8.1,
Lua version: 5.1.5,
Luarocks latest.
Command line:
C:\Users\user\Desktop\luarocks-3.9.2-windows-32>luarocks install winapi
Warning: Lua 5.4 interpreter not found at C:\Users\Didn't understanded word\Desktop\luarocks-3.
9.2-windows-32
Modules may not install with the correct configurations. You may want to configu
re the path prefix to your build of Lua 5.4 using
luarocks config --local lua_dir <your-lua-prefix>
Installing https://luarocks.org/winapi-1.4.2-1.src.rock
Error: Could not fetch rock file: Failed creating temporary directory luarocks-r
ock-winapi-1.4.2-1: Failed setting permission exec for all
C:\Users\user\Desktop\luarocks-3.9.2-windows-32>
Im tried to install without luarocks winapi, but I has got C files and other didn't understanded files.

Error running Fortran on Mac

I am running macOS 10.13.5 and I have installed Fortran using Homebrew. I can compile and build a program like this:
program HelloWorld
write(*,*)'Hello World'
end program
But when I try to run it I get the same error:
dyld: Library not loaded: #rpath/libgfortran.3.dylib
Referenced from: /Users/sergiobacelar/Documents/books2calibre/books_software/feher_fortran/prog01/prog01_01/Build/prog
Reason: image not found
/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/geany_run_script_2Q4DKZ.sh: line 7: 47712 Abort trap: 6 "Build/prog"
I have libgfortran.3.dylib inside anaconda3/lib and I have gcc 8.1.0 in homebrew but when I do gfortran -v I get gcc 4.8.5 from Anaconda.
I use anaconda/miniconda quite a bit on Linux and mac environments. Modules (https://en.wikipedia.org/wiki/Environment_Modules_(software)) are a great way to keep it from polluting your environment. As an example, at the end of my .bashrc file, I have:
module use --append "$HOME/.modules"
This directory contains a module file for conda:
$ cat .modules/conda
#%Module1.0
module-whatis "add ~/miniconda3 to path"
prepend-path PATH /Users/ptb/miniconda3/bin
A $ module load conda will then adjust the PATH, making all miniconda related things visible.
Edit:
I wrote the first part of this answer on my linux machine where modules are installed by default and forgot that 2 things are needed to make it work on a mac.
On a mac, modules can be installed via homebrew with brew install modules. One then needs to put the following before module use ...:
. /usr/local/Modules/default/init/bash

Python 3 installation, additional to existing Python 2 on Windows: Fatal Python error: Py_Initialize: unable to load the file system codec

Sorry if this is a re-post. I have been searching for hours and there are a lot of similar problems, but they are not exactly the same as my issue.
I have been working with Python27 on my 64bit Windows for a while now and I would like to install Python 3 in parallel.
I downloaded and executed the installation .exe of Python 3.5 for 64bit Windows. The installation worked without any errors and added C:/Python35 to the Windows PATH variable.
However, when I click on python.exe in the directory C:\Python35, instead of launching a python 3.5 shell as it's supposed to do, it pops up a Window saying
Python has stopped working
Also there is a command shell saying:
Fatal Python error: Py_Initialize: unable to load the file system
codec File "C:\Python27\Lib\encodings__init__.py", line 123
raise CodecRegistryError,\
^ SyntaxError: invalid syntax
Current thread 0x00001ce0 (most recent call first):
So appearently Python 3.5 is using the Lib directory of Python 2.7. This is probably related to the PYTHONPATH variable that is set to
C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk
When I change the PYHTONPATH variable to
C:\Python35;C:\Python35\Lib;C:\Python27\DLLs;C:\Python35\Lib\lib-tk
Python 3.5 works, but Python 2.7 throws the error above.
Is there any way to permanently define that the command "python3" uses one PYTHONPATH and the command "python2" uses another PYTHONPATH?
Copying python.exe and renaming it to python3.exe didn't help. Neither did uninstalling and installing Python 3.5 again.
I have a lot of old jupyter notebooks that are written in Python 2.7 and it would be great if I could continue to use them by choosing different kernels (see here).

How to install Scrapy on Mac OS X 10.7 ? (lxml error)

I'm a total newbie concerning Python and I have trouble installing Scrapy on Mac OS X 10.7. I've tried a lot of different things, but in summary, when I run:
scrapy startproject tutorial
I've got these errors :
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/lxml/etree.so
After a lot of googling, I've followed this post and tried:
python setup.py build --static-deps --libxml2-version=2.7.8 && pip install lxml
but it tells me:
RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available (pass --without-cython to ignore this error).
And if I run the same command with the —without-cython option, I get:
error: command 'llvm-gcc-4.2' failed with exit status 1
(though I've installed XCode command line tools)
Thanks in advance for your help !
(fyi, I am using MacPorts and pip install…)
You mention Macports at the end and also pip. I think you are mixing up packaging and installation methods.
The first import error should not be seen using a macports python as it puts its libraries under /opt/
As you have started on macports I would use the easy way
port install py27-scrapy
This will install all the needed packages (including python and lxml) to get scrapyto work.
To run scrapy you would need to use the macports python in /opt/local/bin/python2.7. This can be set as the default python if /opt/local/bin is on your path and you run port select to choose this as the python found. The scrapy executable script is /opt/local/bin/scrapy-2.7 Version numbers are used because you can have multiple versions of python working at once.

Can't run luarocks, tonumber is a nil value

To install luarocks, I downloaded the most recent (2.0.11) tar.gx file from here. I unpacked it, and followed the instructions.
$ ./configure
Lua interpreter found: /usr/local/bin/lua...
Lua version detected: 5.1
Looking for Lua...
lua found in $PATH: /usr/local/bin
Checking Lua includes...
lua.h found in /usr/local/include/lua.h
curl found at /usr/bin
openssl found at /opt/local/bin
Configuring for system...
Darwin
Configuring for architecture...
i386
Writing configuration...
Installation prefix: /usr/local
LuaRocks configuration directory: /usr/local/etc/luarocks
Using Lua from: /usr/local
Done. You can now run 'make' to build.
I then ran sudo make install, and finally tried installing a package but when I try to run it I get this error:
$ sudo luarocks install lpeg
/usr/local/bin/lua: /usr/local/share/lua/5.1//luarocks/cfg.lua:355: attempt to call global 'tonumber' (a nil value)
stack traceback:
/usr/local/share/lua/5.1//luarocks/cfg.lua:355: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1//luarocks/command_line.lua:6: in main chunk
[C]: in function 'require'
/usr/local/bin/luarocks:4: in main chunk
[C]: ?
Running lua manually, tonumber works just fine as does everything else. I don't know why it's failing here.
At the top of cfg.lua you need to add
local tonumber = tonumber
before the module call. You can include tonumber in both lines of the list of similar local definitions. You can make these changes in the installed version in /usr/local/share/lua/5.1//luarocks/cfg.lua or in the source version and make install once again.
This is a bug in luarocks and will be fixed in the next release.
My modified luarocks-2.0.11/src/luarocks/cfg.lua contains:
local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION =
rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert, tonumber, _VERSION
module("luarocks.cfg")

Resources