Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Amazon EC2实例中设置Flask应用程序,获取ImportError:没有名为Flask的模块_Python_Apache_Python 2.7_Amazon Web Services_Amazon Ec2 - Fatal编程技术网

Python 在Amazon EC2实例中设置Flask应用程序,获取ImportError:没有名为Flask的模块

Python 在Amazon EC2实例中设置Flask应用程序,获取ImportError:没有名为Flask的模块,python,apache,python-2.7,amazon-web-services,amazon-ec2,Python,Apache,Python 2.7,Amazon Web Services,Amazon Ec2,我在Amazon EC2服务器上部署Flask应用时遇到问题 我遵循了一个教程,然后开始学习 当我运行我的服务器时,在执行sudoapachect1重新启动后导航到我的ec2站点时,我得到一个500内部错误。检查日志时,我发现以下错误 [Tue Jun 20 19:10:48.429468 2017] [wsgi:error] ImportError: No module named flask, referer: http://ec2-<MY-EC2-URL>.amazonaws.

我在Amazon EC2服务器上部署Flask应用时遇到问题

我遵循了一个教程,然后开始学习

当我运行我的服务器时,在执行
sudoapachect1重新启动后
导航到我的ec2站点时,我得到一个500内部错误。检查日志时,我发现以下错误

[Tue Jun 20 19:10:48.429468 2017] [wsgi:error] ImportError: No module named flask, referer: http://ec2-<MY-EC2-URL>.amazonaws.com/
我认为这可能是找不到Python路径的问题。因此,我在apache的配置文件中添加了
python路径=/usr/lib/python2.7

000 default.conf

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    WSGIDaemonProcess leu threads=5 python-path=/usr/lib/python2.7
    WSGIScriptAlias / /var/www/html/leu/app.wsgi

    <Directory leu>
        WSGIProcessGroup leu
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
有什么帮助吗

编辑:
还尝试将上面我的Apache配置文件中Python的路径更改为
/usr/local/lib/python2.7
,但仍然没有成功

使用sudo-H安装模块
如果仍然存在,那么您必须更改配置以使用python 2.7而不是python 3

我知道我已经太迟了……希望这对正在挣扎的人有用

ServerName your EC2 instance

您必须提到您的EC2实例

我认为第一步是确保您可以在本地访问服务器。本地主机:在EC2上。然后在尝试从浏览器访问EC2实例时,检查该实例的传入端口设置是否打开
import sys
sys.path.insert(0, 'var/www/html/leu')

from app import app as application
ServerName your EC2 instance