标签: python

在 yum 更新期间,Python 安装会更新。我需要重新启动正在运行的程序吗?

正如标题所说。如果我运行 yum update(它是一个 CentOS 机器)并且恰好有一个 Python 更新。如果其他用户运行 Python 程序会发生什么。我需要提醒他们重新启动程序吗?或者,如果他们愿意,他们可以基本上无限期地安全地继续运行这些程序吗?

换个方式问:只要有一些进程仍然打开,旧的 Python 版本是否会保留在系统(硬盘驱动器)上。还是更新会立即覆盖现有的 Python 安装/二进制文件?那么现有的进程继续运行只是因为 Python 解释器完全加载到内存中?

linux python centos yum

7
推荐指数
1
解决办法
209
查看次数

如果文件不存在,如何告诉 Puppet 仅使用 Pip 进行安装

我正在使用 Puppet 使用 pip 安装一些 Python 包。我使用的是 Puppet 2.7,所以我的包声明看起来像这样:

package { "carbon": 
    require => Class["graphite::prereqs::install"],
    ensure  => latest,
    provider => pip,
}
Run Code Online (Sandbox Code Playgroud)

问题是这个包和graphite-web包似乎都有一个错误,可以使用 pip 多次安装相同的版本。所以如果我sudo pip install carbon多次输入,pip 每次都会安装它。我相信这是软件包的错误。

这个错误似乎也让 Puppet 感到困惑,因为每次我配置我的系统carbongraphite-web重新安装时。

因此,我想知道是否有办法解决这个明显的打包错误。我尝试了以下方法:

package { "carbon": 
    require => Class["graphite::prereqs::install"],
    ensure  => latest,
    provider => pip,
    creates => "/opt/graphite/bin/carbon-cache.py",
}
Run Code Online (Sandbox Code Playgroud)

...但我不能使用创建。有没有另一种方法可以告诉包声明在安装包之前查找文件?

python puppet pip graphite

6
推荐指数
1
解决办法
1万
查看次数

Ubuntu - Supervisord 和 virtualenv

我正在尝试从主管运行一系列 Python 应用程序。它在 Mac OSX 上运行良好,但是当我尝试在 Ubuntu 上运行相同的应用程序时,主管似乎没有激活 virtualenv,因此我的脚本抛出错误。

这是我的结构:

/home/user/Sites/my-site
- app.py
- venv
- supervisor.conf
Run Code Online (Sandbox Code Playgroud)

我的 supervisor.conf 文件如下所示:

[program:python-app]
autorestart = false
autostart = false
startsecs = 0
command = python app.py
startretries = 1
environment=PYTHONPATH="%(here)s"

[unix_http_server]
file = /tmp/supervisor.sock

[supervisord]
logfile = logs/supervisord.log
pidfile = logs/supervisord.pid
environment=PYTHONPATH="%(here)s"

[supervisorctl]
serverurl = unix:///tmp/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[unix_http_server]
username = supervisor_admin
password = 

[inet_http_server]
username = supervisor_admin
password = 
port = *:9001
Run Code Online (Sandbox Code Playgroud)

如何让主管在虚拟环境中运行 python 应用程序?

ubuntu python virtualenv supervisord

6
推荐指数
1
解决办法
2万
查看次数

我可以在端口 80 上运行两个服务器应用程序吗?

我目前在端口 80 上运行 nginx,配置的服务器名称为example.comwww.example.com

我还有一个Flask应用程序,我想通过端口 80 访问它,但使用主机名app.example.com

由于 nginx 已经在使用端口 80,我将如何将app.example.com请求路由到 Flask 应用程序?

请注意,服务器只有一个 IPv4 地址。

networking python nginx domain port

6
推荐指数
1
解决办法
1万
查看次数

慢速 Memcached:平均 10 毫秒 memcached `get`

我们正在使用 Newrelic 来衡量我们的 Python/Django 应用程序性能。Newrelic 报告说,在我们的系统中,“Memcached”正在平均12ms响应命令。

深入到前十个左右的 Web 视图(按请求数),我可以看到有些Memcache get30ms; 我无法Memcache get在小于10ms.

有关系统架构的更多详细信息:

  • 目前我们有四台应用服务器,每台服务器都有一个 memcached 成员。所有四个 memcached 成员都参与了一个 memcache 集群。
  • 我们在云托管提供商上运行,所有流量都在“内部”网络上运行(通过“内部”IP)
  • 当我从一个应用程序服务器 ping 到另一个应用程序服务器时,响应在 ~0.5ms

Memcached 的响应时间不是10ms吗?

据我了解,如果您认为“Memcache 太慢”那么“您做错了”。那我做错了吗?

这是memcache-top命令的输出:

memcache-top v0.7   (default port: 11211, color: on, refresh: 3 seconds)

INSTANCE        USAGE   HIT %   CONN    TIME    EVICT/s GETS/s  SETS/s  READ/s  WRITE/s 
cache1:11211    37.1%   62.7%   10      5.3ms   0.0     73      9       3958 …
Run Code Online (Sandbox Code Playgroud)

memory python cache memcached

6
推荐指数
1
解决办法
2万
查看次数

无法从 uwsgi 加载配置

从昨天开始我就一直在纠结这个问题:无法从 uwsgi 加载配置

当我谷歌它时,什么也没有出现。我正在尝试使用非常简单的 uwsgi.ini 文件在 nginx 下运行 UWSGI。文件被正确指向。

谁能解释一下这个错误是什么,以及我如何诊断和修复它。如果有更多信息我可以发布以提供帮助,请询问。

问候,

詹姆士

debian python nginx uwsgi

6
推荐指数
1
解决办法
2万
查看次数

uWSGI 权限问题

我正在尝试设置一个厨师食谱,以使我的网站运行,并且一切似乎都运行良好,但uWSGI出现以下错误:

*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from app-cms.ini
removed uwsgi instance app-cms.ini
Run Code Online (Sandbox Code Playgroud)

不再说这个:

open("/var/www/app-cms/logs/uwsgi.log"): Permission denied [utils.c line 246]
Run Code Online (Sandbox Code Playgroud)

现在正在创建该日志文件,其中包含以下内容:

*** Starting uWSGI 1.0.3-debian (64bit) on [Thu Feb  6 12:00:43 2014] ***
compiled with version: 4.6.3 on 17 July 2012 02:26:54
current working directory: /etc/uwsgi/apps-enabled
writing pidfile to /var/www/ediflo-cms/run/ediflo-cms.pid
detected binary path: /usr/bin/uwsgi-core
setgid() to 33
setuid() to 33
chdir(): Permission denied [uwsgi.c line 1723]
chdir(): Permission denied [uwsgi.c line 975]
Run Code Online (Sandbox Code Playgroud)

我不确定它试图去哪里 …

python nginx chef uwsgi

6
推荐指数
1
解决办法
8842
查看次数

python boto3 允许入口安全组

我正在开发一个简单的 python 脚本来向安全组添加规​​则,我想知道 boto3 中可用的两种方法之间有什么区别:authorize_security_group_ingress(**kwargs)authorize_ingress(**kwargs)

描述相同:“向安全组添加一个或多个入口规则”

python amazon-web-services aws-cli boto security-groups

6
推荐指数
1
解决办法
8600
查看次数

如何获取 Google Cloud Storage 中文件的下载 URL?

我使用以下方法创建了一项服务:

storage.Client(project='project_name',credentials=credentials)

https://googleapis.dev/python/storage/latest/client.html

我可以上传、删除和列出用户 Google Cloud 存储桶中的文件。我看到了将文件下载到服务器的选项,但是是否有任何选项可以获取可下载链接?

python google-cloud-storage google-cloud-platform

6
推荐指数
1
解决办法
2万
查看次数

如何让mod_wsgi使用Python 3.9?

我最初安装了 Python 3.6,并且在我的 Linux 服务器上与 WSGI 和 Apache2 配合得很好。

然后我创建了一个 Flask 应用程序,它有一个需要 Python 3.7 的依赖项。我已经成功(并且我认为)升级到 Python 3.9。跑步

python3或者sudo python3

两者都带我到 Python 3.9。但当我跑步时

sudo apt-get install libapache2-mod-wsgi-py3
The following additional packages will be installed: python3, python3.6
Run Code Online (Sandbox Code Playgroud)

它安装Python 3.6

此后,python3仍然指向Python 3.9。但是,当运行 WSGI 应用程序时,使用 Python 3.6,并且它会崩溃。mod-wsgi我已经使用正确的 PIP安装了 Python 包。

python mod-wsgi apache2

6
推荐指数
1
解决办法
6724
查看次数