Installing mod_wsgi-3.4 to go with python 3.4 - python

I am trying to run a flask app on an apache server so I am using mod_wsgi to deploy it. I downloaded python 3.4 from source and compiled it and it runs just fine. Now I did this:
cd
wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
tar -zxf mod_wsgi-3.4.tar.gz
cd mod_wsgi-3.4
sudo ./configure --with-python=/usr/local/opt/python-3.4.1/bin/python3.4
make
But when I run make I get this error chain:
/usr/bin/apxs2 -c -I/usr/local/opt/python-3.4.1/include/python3.4m -DNDEBUG mod_wsgi.c -L/usr/local/opt/python-3.4.1/lib -L/usr/local/opt/python-3.4.1/lib/python3.4/config -lpython3.4 -lpthread -ldl -lutil -lm
Use of uninitialized value $includedir in concatenation (.) or string at (eval 9) line 1.
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static x86_64-linux-gnu-gcc -prefer-pic -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I/usr/include -I/usr/include/apr-1.0 -I/usr/include/openssl -I/usr/include/xmltok -pthread -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -I -I. -I/usr/include -I/usr/include/apr-1.0 -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -I/usr/local/opt/python-3.4.1/include/python3.4m -DNDEBUG -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
/usr/share/apr-1.0/build/libtool --silent --mode=link --tag=disable-static x86_64-linux-gnu-gcc -Wl,--as-needed -Wl,-z,relro -o mod_wsgi.la -rpath /usr/lib/apache2/modules -module -avoid-version mod_wsgi.lo -L/usr/local/opt/python-3.4.1/lib -L/usr/local/opt/python-3.4.1/lib/python3.4/config -lpython3.4 -lpthread -ldl -lutil -lm
/usr/bin/ld: cannot find -lpython3.4
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wsgi.la] Error 1
And I just don't know what to make of it. And ideas?

Related

Yocto compilation of my source code return error cannot find -lpython3.8

I'm trying to integrate the compilation of my source code into my recipe in yocto.
When I extract the yocto toolchain and compile myself it works.
Here is the compiler and my makefile in this case:
echo $CC
aarch64-poky-linux-gcc -mcpu=cortex-a72+crc+crypto -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/norian/Yocto/sysroots/aarch64-poky-linux
CFLAGS = -g -Wall -O
INCLUDES = -I /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/recipe-sysroot-native/usr/include/python3.8
LIBS = -lrt -lpthread -lpython3.8
SRCS = main.c config_radio.c
OBJS = $(SRCS:.c=.o)
MAIN = radio
.PHONY: depend clean
all: $(MAIN)
#echo radio has been compiled
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $#
clean:
$(RM) *.o *~ $(MAIN)
depend: $(SRCS)
makedepend $(INCLUDES) $^
But if I try to compile my source code from a yocto recipe I get this error:
| /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/recipe-sysroot-native/usr/include/python3.8/Python.h:44:10: fatal error: crypt.h: No such file or directory
| 44 | #include <crypt.h>
So to correct this I modify INCLUDES in my makefile :
INCLUDES = -I /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/recipe-sysroot-native/usr/include/python3.8 -I /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/sdk/image/usr/local/oe-sdk-hardcoded-buildpath/sysroots/aarch64-poky-linux/usr/src/debug/libxcrypt/4.4.15-r0/build
But then I get the following error:
| aarch64-poky-linux-gcc -mcpu=cortex-a72+crc+crypto -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/norian/Yocto/build-rpi/tmp/work/aarch64-poky-linux/radio-makefile/1.0-r0/recipe-sysroot -g -Wall -O -I /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/recipe-sysroot-native/usr/include/python3.8 -I /home/norian/Yocto/build-rpi/tmp/work/raspberrypi4_64-poky-linux/radio-image/1.0-r0/sdk/image/usr/local/oe-sdk-hardcoded-buildpath/sysroots/aarch64-poky-linux/usr/src/debug/libxcrypt/4.4.15-r0/build -o radio main.o config_radio.o -lrt -lpthread -lpython3.8
| /home/norian/Yocto/build-rpi/tmp/work/aarch64-poky-linux/radio-makefile/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/9.3.0/ld: cannot find -lpython3.8
| collect2: error: ld returned 1 exit status
| make: *** [Makefile:21: radio] Error 1
Can you explain to me this problem and how to solve it please ?

Compiling C with Python3.10 and OpenSSL-1.1: undefined symbol "OPENSSL_sk_num"

The configure script for nginx/unit fails because it is not able compile python extension code shown below:
#include <Python.h>
int main() {
Py_Initialize();
return 0;
}
I am using python3.10 which is compiled with openssl-1.1.1.
The compilation gives several symbol not found error including "OPENSSL_sk_num". It seems the symbol is in libcrypto which I have linked in the compile command manually.
Do I need to compile Python again so as to statically link libcrypto and libssl in libpython.a? Below is the full compile command.
cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g -I/home/shared/Builds/Python-3.1
0.0/include/python3.10 -I/home/shared/Builds/Python-3.10.0/include/python3.10 -o build/autotest build/autotest.c -L/home/shared/Builds/Python-3.10.0/lib/python3.10/config-3.10 -L/home/shared/Buil
ds/Python-3.10.0/lib -lcrypto -lssl -lpython3.10 -lpthread -lutil -lm -lm
Luckily, found the fix. Following works -- not sure why
cc -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g -I/home/shared/Builds/Python-3.10.0/include/python3.10 -I/home/shared/Builds/Python-3.10.0/include/python3.10 -o build/autotest build/autotest.c -L/home/shared/Builds/Python-3.10.0/lib/ -lpython3.10 -lpthread -lutil -lm -L/usr/local/lib/eopenssl11 -lssl -lcrypto
-lpython3.10 has to precede before -lssl which precedes -lcrypto.

Psycopg2-binary installation issue

While installing psycopg2 binary python package, am getting the below error
copg/typecast.c -o build/temp.linux-x86_64-3.7/psycopg/typecast.o -Wdeclaration-after-statement
gcc -pthread -shared -B /data/softwares/AnacondaPackages/anaconda3/compiler_compat -L/data/softwares/AnacondaPackages/anaconda3/lib -Wl,-rpath=/data/softwares/AnacondaPackages/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -Wl,-O2,--sort-common,--as-needed,-z,relro,-z,now -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -D_FORTIFY_SOURCE=2 -O2 build/temp.linux-x86_64-3.7/psycopg/psycopgmodule.o build/temp.linux-x86_64-3.7/psycopg/green.o build/temp.linux-x86_64-3.7/psycopg/pqpath.o build/temp.linux-x86_64-3.7/psycopg/utils.o build/temp.linux-x86_64-3.7/psycopg/bytes_format.o build/temp.linux-x86_64-3.7/psycopg/libpq_support.o build/temp.linux-x86_64-3.7/psycopg/win32_support.o build/temp.linux-x86_64-3.7/psycopg/solaris_support.o build/temp.linux-x86_64-3.7/psycopg/connection_int.o build/temp.linux-x86_64-3.7/psycopg/connection_type.o build/temp.linux-x86_64-3.7/psycopg/cursor_int.o build/temp.linux-x86_64-3.7/psycopg/cursor_type.o build/temp.linux-x86_64-3.7/psycopg/replication_connection_type.o build/temp.linux-x86_64-3.7/psycopg/replication_cursor_type.o build/temp.linux-x86_64-3.7/psycopg/replication_message_type.o build/temp.linux-x86_64-3.7/psycopg/diagnostics_type.o build/temp.linux-x86_64-3.7/psycopg/error_type.o build/temp.linux-x86_64-3.7/psycopg/lobject_int.o build/temp.linux-x86_64-3.7/psycopg/lobject_type.o build/temp.linux-x86_64-3.7/psycopg/notify_type.o build/temp.linux-x86_64-3.7/psycopg/xid_type.o build/temp.linux-x86_64-3.7/psycopg/adapter_asis.o build/temp.linux-x86_64-3.7/psycopg/adapter_binary.o build/temp.linux-x86_64-3.7/psycopg/adapter_datetime.o build/temp.linux-x86_64-3.7/psycopg/adapter_list.o build/temp.linux-x86_64-3.7/psycopg/adapter_pboolean.o build/temp.linux-x86_64-3.7/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-3.7/psycopg/adapter_pint.o build/temp.linux-x86_64-3.7/psycopg/adapter_pfloat.o build/temp.linux-x86_64-3.7/psycopg/adapter_qstring.o build/temp.linux-x86_64-3.7/psycopg/microprotocols.o build/temp.linux-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.linux-x86_64-3.7/psycopg/typecast.o -L/usr/local/pgsql/lib -lpq -o build/lib.linux-x86_64-3.7/psycopg2/_psycopg.cpython-37m-x86_64-linux-gnu.so
gcc: error: unrecognized command line option ‘-fno-plt’
error: command 'gcc' failed with exit status 1
I found out it is using GCC w.r.t to OS but i want GCC of conda to be used for the installation.
pip install psycopg2-binary.tar.gz (Offline installation)

error: command 'c++' failed with exit status 1

So I am trying to install Pyv8 by following instruction from https://andrewwilkinson.wordpress.com/2012/01/23/integrating-python-and-javascript-with-pyv8/
sudo aptitude install scons libboost-python-dev
svn checkout http://v8.googlecode.com/svn/trunk/ v8
svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8
cd v8
export PyV8=`pwd`
cd ../pyv8
python setup.py build
sudo python setup.py install
Error comes when running second last command about building the setup.
-Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -
DV8_NATIVE_REGEXP -DENABLE_DEBUGGER_SUPPORT -DV8_TARGET_ARCH_X64 -
I/home/amit/Downloads/pyv8/build/v8_r19632/include -
I/home/amit/Downloads/pyv8/build/v8_r19632 -
I/home/amit/Downloads/pyv8/build/v8_r19632/src -I/usr/local/include -
I/usr/include/python2.7 -c src/PyV8.cpp -o build/temp.linux-x86_64-
2.7/src/PyV8.o -Wno-write-strings -g -O3
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for
C/ObjC but not for C++ [enabled by default]
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-
functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-
buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-
2.7/src/Utils.o build/temp.linux-x86_64-2.7/src/Exception.o
build/temp.linux-x86_64-2.7/src/Context.o build/temp.linux-x86_64-
2.7/src/Engine.o build/temp.linux-x86_64-2.7/src/Wrapper.o
build/temp.linux-x86_64-2.7/src/Debug.o build/temp.linux-x86_64-
2.7/src/Locker.o build/temp.linux-x86_64-2.7/src/AST.o build/temp.linux-
x86_64-2.7/src/PrettyPrinter.o build/temp.linux-x86_64-2.7/src/PyV8.o
L/usr/local/lib -
L/home/amit/Downloads/pyv8/build/v8_r19632/out/x64.release/obj.target/tool
s/gyp/ -lboost_python -lboost_thread -lboost_system -lrt -lv8_base.x64 -
lv8_snapshot -o build/lib.linux-x86_64-2.7/_PyV8.so -fPIC -lrt
/usr/bin/ld: cannot find -lboost_thread
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
error: command 'c++' failed with exit status 1
It is because the version of gcc and g++ is too low for me, as I downgrade it when i install cuda sometime. Just follow the following commands:
$ cd /usr/bin
$ rm gcc
$ ln -s gcc-5 gcc
$ rm g++
$ ln -s g++-5 g++
Done.
I followed the instructions from this link - http://ubuntuforums.org/showthread.php?t=1480282#post_11247864
and installed the libboost_thread package which solved the problem. Thank you https://stackoverflow.com/users/440558/joachim-pileborg

Unable to install MySQL-python under ubuntu 12.04

I'm trying to install mysql-python module in ubuntu 12.04 under virtualenv environment but unexpectedly faced with error below:
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:97:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:107:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
-Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu
-lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
I've run:
sudo apt-get install mysql-server mysql-client python-mysqldb libmysqlclient-dev python-dev
but it didn't help.
The problem was that libmysqlclient.so didn't have symlinks described in https://github.com/javer/gentoo-overlay/issues/4#issuecomment-30748799
For me on Centos, the problem was that MySQL-python did not provide the libmysqlclient_r.so but it had the other numbered versions. By uninstalling it and installing Percona-SQL-devel instead, python was able to find the library and build wheel correctly.

Categories