Installing mod_wsgi for Python 3.7 virtualenv
mod_wsgi virtualenv flask
yum install mod_wsgi python 3
deploy django on apache with virtualenv and mod_wsgi
macos install mod_wsgi
conda install mod_wsgi
Trying to install mod_wsgi for Python 3.7 to complete setup of Django. But it fails with following error message
Collecting mod-wsgi Using cached https://files.pythonhosted.org/packages/9e/37/dd336068ece37c43957aa337f25c59a9a6afa98086e5507908a2d21ab807/mod_wsgi-4.6.4.tar.gz Building wheels for collected packages: mod-wsgi Running setup.py bdist_wheel for mod-wsgi ... error Complete output from command /home/user/myproject_env/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9hnl4thc/mod-wsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-a9t55ene --python-tag cp37: WARNING: The Python installation you are using does not appear to have been installed with a shared library, or in the case of MacOS X, as a framework. Where these are not present, the compilation of mod_wsgi may fail, or if it does succeed, will result in extra memory being used by all processes at run time as a result of the static library needing to be loaded in its entirety to every process. It is highly recommended that you reinstall the Python installation being used from source code, supplying the '--enable-shared' option to the 'configure' script when configuring the source code prior to building and installing it. ... running build_ext building 'mod_wsgi.server.mod_wsgi-py37' extension creating build/temp.linux-x86_64-3.7 creating build/temp.linux-x86_64-3.7/src creating build/temp.linux-x86_64-3.7/src/server ... gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/httpd -I/home/user/python/include/python3.7m -c src/server/wsgi_stream.c -o build/temp.linux-x86_64-3.7/src/server/wsgi_stream.o -I/usr/include/httpd -I. -I/usr/include/apr-1 -DLINUX -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -pthread -I/usr/include/apr-1 -I/usr/include/apr-1 gcc -pthread -shared build/temp.linux-x86_64-3.7/src/server/wsgi_thread.o build/temp.linux-x86_64-3.7/src/server/mod_wsgi.o build/temp.linux-x86_64-3.7/src/server/wsgi_buckets.o build/temp.linux-x86_64-3.7/src/server/wsgi_memory.o build/temp.linux-x86_64-3.7/src/server/wsgi_interp.o build/temp.linux-x86_64-3.7/src/server/wsgi_restrict.o build/temp.linux-x86_64-3.7/src/server/wsgi_logger.o build/temp.linux-x86_64-3.7/src/server/wsgi_server.o build/temp.linux-x86_64-3.7/src/server/wsgi_convert.o build/temp.linux-x86_64-3.7/src/server/wsgi_metrics.o build/temp.linux-x86_64-3.7/src/server/wsgi_validate.o build/temp.linux-x86_64-3.7/src/server/wsgi_daemon.o build/temp.linux-x86_64-3.7/src/server/wsgi_apache.o build/temp.linux-x86_64-3.7/src/server/wsgi_stream.o -o build/lib.linux-x86_64-3.7/mod_wsgi/server/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so -L/home/user/python/lib -L/home/user/python/lib/python3.7/config-3.7m-linux -lpython3.7m /usr/bin/ld: /home/user/python/lib/libpython3.7m.a(abstract.o): relocation R_X86_64_32S against symbol `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC ... /usr/bin/ld: /home/user/python/lib/libpython3.7m.a(getopt.o): relocation R_X86_64_32S against `.rodata.str4.4' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /home/user/python/lib/libpython3.7m.a(parser.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/home/user/myproject_env/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-9hnl4thc/mod-wsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-fxo44dv3/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/myproject_env/include/site/python3.7/mod-wsgi" failed with error code 1 in /tmp/pip-install-9hnl4thc/mod-wsgi/
Here is the version information:
Apache 2.4.6 CentOS 7 Python 3.7.0 Django 2.0.5
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) httpd-devel-2.4.6-80.el7.centos.1.x86_64
mod-wsgi · PyPI, The second way of installing mod_wsgi is to install it as a Python package into your Python installation using the Python pip install command. This can be used Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories and environment. This doesn’t share libraries with other environments. It is very helpful for the application required separate environments on the same server.
As the warning from installation indicates, you're attempting to install
mod-wsgi into a python which does not provide a shared object.
python from source, add the
--enable-shared flag so that it produces a
libpython#.#.so shared object which can be linked against
Virtual Environments, You can use a Python virtual environment created using virtualenv and How you configure mod_wsgi or setup your WSGI application script file for a Python This custom installation of Python 3 will also contain pip3. After it's installed and activated , run the which python3 command as shown in the article. This should return the location of your custom version of Python 3.
Thanks @Graham Dumpleton for sharing the useful links.
I have installed python from source packages with only --enable-shared, so got error "python: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory" when tried to install packages via pip3
so did the below steps to make it work.
./configure --prefix /usr/local --enable-shared LDFLAGS="-Wl,-rpath,/usr/local/lib" make make install
now pip3 install mod-wsgi worked fine.
Rebuild / Reconfigure mod_wsgi for python 3.7 · Issue #467 , Using pip install mod_wsgi to install mod_wsgi into your Python 3.7 virtual environment (needs to be 3.7, can't use 3.6 environment nor can you Installer for Apache/mod_wsgi. The mod_wsgi package provides an Apache module that implements a WSGI compliant interface for hosting Python based web applications on top of the Apache web server. Installation of mod_wsgi from source code can be performed in one of two ways. The first way of installing mod_wsgi is the traditional way that has
How to Run Django with mod_wsgi and Apache with a virtualenv , The local instance of pip installs all packages inside the virtual environment. That way no installed packages pollute global Python installation install mod_wsgi on python and apache; setup httpd.conf on apache; configure python script (usually wsgi.py) that is loaded by mod_wsgi and in turn loads your python app; 1. Is described well enough in the official doc (I used the pip method).
How to Install and Use virtualenv with Python 3 – TecAdmin, Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories and environment. I'm trying to set up a standard virtualenv with python 3.7 on Ubuntu 18.04, with pip (or some way to install packages in the virtualenv). The standard way to install python3.7 seems to be: % sudo apt install python3.7 python3.7-venv % python3.7 -m venv py37-venv but
How to install Django | Django documentation, In embedded mode, mod_wsgi is similar to mod_perl – it embeds Python This is the recommended way to install Django. Install pip. The easiest is to use the In 3.7.2 only setup_python() does nothing unless running from a build in the source tree. Changed in version 3.7.3: Windows copies the redirector scripts as part of setup_python() instead of setup_scripts(). This was not the case in 3.7.2. When using symlinks, the original executables will be linked.
- you have not pasted enough of the error message -- include the full output please. The useful information is usually right above what you've pasted.
- that aside, purely guessing you're probably missing
- gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) httpd-devel-2.4.6-80.el7.centos.1.x86_64
- paste the
pip installcommand and its full output
- I've updated the original post with a snippet of that install log