如何制作交流的Apache和Virtualenv?

时间:2018-06-19 13:36:55

标签: python flask virtualenv mod-wsgi

>>source ~/.profile 
>>workon insta
>>pip install PyMySQL
>>pip freeze

我看到PyMySQL == version。 (insta是我的虚拟环境的名称)

>>python
>>import PyMySQL

没有错误是可以的。

但是,如果我从apache服务器运行它,则会收到“没有名为PyMySQL的模块”错误。 PyMySQL已安装在/home/pi/.virtualenvs/insta/lib/python3.5/site-packages/pymysql

/ home / pi / Public / insta / init .py

from flask import Flask, render_template, flash, request, redirect
import pymysql

app = Flask(__name__)

长颈瓶没有错误。因为它从主site-packages目录获取Flask。不是来自virtualenv。

我的wsgi设置为:

/home/pi/Public/insta/FlaskApp.wsgi

import sys 
sys.path.insert(0, '/home/pi/Public/insta') 
from __init__ import app as application

/etc/apache2/sites-available/FlaskApp.conf

<VirtualHost *:80>
        ServerName my ip address
        ServerAdmin email.com
        WSGIScriptAlias / /home/pi/Public/insta/FlaskApp.wsgi
        <Directory /home/pi/Public/insta/>
            Order allow,deny
            Allow from all
        </Directory>
        Alias /static /home/pi/Public/insta/static
        <Directory /home/pi/Public/insta/static/>
            Order allow,deny
            Allow from all
        </Directory>
        ErrorLog /home/pi/Public/insta/logs/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我问apgi服务器和虚拟环境目录在wsgi端是否断开连接。如何连接它们并使apache查看已安装的venv模块?

0 个答案:

没有答案