我正在使用 pyinstaller 为使用 Pandas 和 sklearn 的 python 程序创建一个 .exe。pyinstaller 进程按预期完成并生成带有可执行文件的 dist 文件夹。但是,当我运行 .exe 时,出现与 sklearn 和 scipy 相关的模块导入错误。
我创建了一个测试脚本 (test.py) 来测试导入,它只导入 pandas 和 sklearn,然后打印成功消息:
import time
import pandas as pd
import sklearn
def main():
print('hello world!')
time.sleep(5)
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
我知道 pyinstaller hooks 并且我能够通过向 pyinstaller hooks 目录添加一个钩子来解决 pandas 错误。我为 sklearn 和 scipy 添加了类似的钩子,看起来它们正在运行,但是在 pyinstaller 输出中,我收到了“找不到隐藏导入“sklearn.utils.sparsetools._graph_validation”的警告!和类似的'._graph_tools'。
这是 scipy 的钩子(hook-scipy.py):
print('loading custome hook for scipy')
from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules('scipy')
Run Code Online (Sandbox Code Playgroud)
这是运行 pyinstaller 生成的警告的快照

这是运行 test.exe 时错误的快照

我在一个安装了 …
在运行Nginx的EC2实例前面使用AWS Elastic Load Balancer(应用程序类型)时,我遇到了HTTPS请求的"502 Bad Gateway"问题.Nginx在服务于python应用程序(金字塔框架)的服务器服务器的每个实例上充当反向代理.我正在尝试在ELB上使用TLS终止,以便EC2实例仅处理HTTP.这是粗略的设置:
客户端HTTPS请求> ELB(侦听443,在后端转发到80)> Nginx侦听端口80(在Ec2实例上)>转发到waitress/Pyramid(在同一个ec2实例上)
当我在HTTPS上发出请求时,我收到502错误.但是,当我发出常规HTTP请求时,我会得到预期的响应(与上面相同的设置,除了ELB正在侦听端口80).
一些额外的信息:ELB健康检查正在运行.所有VPC /安全组都配置正确(我相信).我正在使用AWS上的标准设置/演练在ELB上使用AWS证书.我通过SSH进入Ec2实例和Nginx访问日志,看起来HTTPS请求仍然是加密的?还是一些编码问题?
这是EC2实例上的nginx.conf:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /etc/nginx/access.log;
sendfile on;
# Configuration containing list of application servers
upstream app_servers {
server 127.0.0.1:6543;
}
server {
listen 80;
server_name [MY-EC2-SERVER-NAME];
# Proxy connections to the application servers
# app_servers
location / {
proxy_pass http://app_servers;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
} …Run Code Online (Sandbox Code Playgroud)