Django on apache: Could not find platform dependent libreries <exe_prefix>

I'm trying to deploy a django app in an Apache Server (Wamp) using a virtual environtment, but getting that error. Everything is going well, the problem seems to be happen in the wsgi.py file.

The wsgi.py never start the venv so this never start the app.

Here is my httpd-vhost.conf:

    ServerName my.app.name
    ServerAdmin myadminname@localhost.com
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    WSGIPassAuthorization On
    
    Alias /static C:/wamp/apache2/htdocs/<myappname>/frontend/build/static/
    <Directory "C:/wamp/apache2/htdocs/<myappname>/frontend/build/static/">
        Allow from all
        Require all granted
    </Directory>
    
    <Directory "C:/wamp/apache2/htdocs/<myappname>/<mysetting's django folder>">
        <Files wsgi.py>
            Allow from all
            Require all granted
        </Files>
    </Directory>
    
    #WSGIDaemonProcess <my.app.group> python-path="C:/wamp/apache2/htdocs/<app.name>/env/Lib/site-packages"
    #WSGIProcessGroup <my.app.group>
    WSGIScriptAlias / "C:/wamp/apache2/htdocs/<app.name>/<settings folder>/wsgi.py"
    
</VirtualHost>

Here is my wsgi.py file:



import os
import sys

# Add the virtual environment path to the system path
sys.path.append('C:/wamp/apache2/htdocs/<app.name>/env/Lib/site-packages')

# activate_this = 'C:/wamp/apache2/htdocs/<app.name>/env/Scripts/activate_this.py'
# execfile(activate_this, dict(__file__=activate_this))
# exec(open(activate_this).read(),dict(__file__=activate_this))

# Activate the virtual environment
activate_env = 'C:/wamp/apache2/htdocs/<app.name>/env/Scripts/python'
exec(open(activate_env, 'rb').read(), {'__file__': activate_env})

# Set the DJANGO_SETTINGS_MODULE environment variable
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')

os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'

# Import the Django application from the Django project
from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

In the wsgi.py file there are two ways I found for activate the venv. The venv don't have the activate_this.py file but there was an answer I found answer-here that say you simply copying it from the virtualenv package solve the problem. I tried and worked (in Windows 10). But then I tried in a lower Windows version and got that error. Then I found the other solution without the activate_this.py file but still don't work.

Hope someone can help me. Thanks in advance.

Back to Top