AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-984498

sogu's questions

Martin Hope
sogu
Asked: 2021-05-30 05:47:31 +0800 CST

如何在 crontab 中使用 Anaconda 环境运行我的 Python 脚本?

  • 0

我想用 crontab 安排一个任务,每天在特定的时间在特定的 anaconda 环境中运行 python 文件。我有一个 python 脚本可以这样做。

python h.py如果我只是在终端的 anaconda 环境中执行它,python 脚本就会运行。h.py位于主目录中。

我使用的是 Ubuntu 20.04,我没有刷新或安装任何新的 cron 或 crontab

我已经尝试了以下命令来让它工作,但它们什么都不做(结果应该是一个文件夹,它显然没有被创建)

crontab -e

在 crontab 内部:

#[long descriptional text]
...
53 13 * * * cd /home/ && /home/user/anaconda3/envs/rapids/bin/python h.py    

这也无济于事:没有错误消息

我还尝试了以下方法:

32 14 * * * cd /home/Documents && /home/user/anaconda3/envs/rapids/bin/python h.py

和

34 14 * * * cd /home/Documents && /home/anaconda3/envs/rapids/bin/python h.py 2>&1

从Stack Overflow 上的这个答案。

Unix 和 Linux 上的这个答案 不适用于普通的蟒蛇。

我还阅读了以下解决方案,但没有任何效果。

  • 如何从命令行使用 Anaconda 运行 Python 脚本
  • 尽管已安装和配置 crontab,但未找到 crontab 服务文件
  • crontab 不运行 python 脚本
  • 通过 crontab 执行 Python 脚本
  • Crontab Python 脚本不能在 Linux 服务器上与 Anaconda 一起运行

我想到但未尝试过的一件事是按照此答案中的建议为 crontab 安装守护程序,但我找不到要为 Ubuntu 安装的 cronie。

scripts
  • 1 个回答
  • 2351 Views
Martin Hope
sogu
Asked: 2021-05-01 14:58:28 +0800 CST

Anaconda 将“基础”环境永久更改为不同的环境“myenv”以在终端开口处启动

  • 1

我想将base启动终端时启动的安装环境更改为我创建的称为myenvanaconda 环境的不同环境。

我想myenv在每次启动终端时启动。

我已经关闭了启动base环境。

conda config --set auto_activate_base false

我在 Ubuntu 20.04 上。

在我的.bashrc文件中,最后我已经有了一个condainit。我不确定我是否应该处理它。

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/MYUSERNAME/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/nul>
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/MYUSERNAME/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/MYUSERNAME/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/MYUSERNAME/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
command-line
  • 1 个回答
  • 1914 Views
Martin Hope
sogu
Asked: 2020-03-27 08:00:27 +0800 CST

nginx 失败,而网站仍然可以正常工作

  • 0

描述

  • 我根据本指南构建了我的 Django3、gunicorn、nginx、Ubuntu 18.04、Digital Ocean 项目。我只有一个问题,它不显示 CSS 和所有其他静态文件,如图像。在整个指南之前,nginx 已经按照指南所说的给出了正确的答案,而且目前 html 站点仍然在线并正在运行
  • 为了解决这个问题,我正在使用另一个指南来让我的静态文件显示在我的网站上。我已经完成了创建者推荐的所有步骤,但在

我试过的

  • 在以下 [1.2.3...] 命令的每个步骤之后,我执行了以下命令来刷新:

    • python3 manage.py collectstatic
    • sudo nginx -t && sudo systemctl restart nginx
    • sudo systemctl restart gunicorn
  • 1.运行:sudo ln -s /etc/nginx/sites-available/ch-project /etc/nginx/sites-enabled

  • 1.结果:ln: failed to create symbolic link '/etc/nginx/sites-enabled/ch-project': File exists

  • 2.运行:/etc/nginx/sites-enabled/my-project

  • 2.结果:-bash: /etc/nginx/sites-enabled/my-project: Permission denied

  • 3.运行:systemctl status nginx.service

  • 3.结果:
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2020-03-26 13:27:08 UTC; 13s ago
     Docs: man:nginx(8)
  Process: 11111 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 11111 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 11111 (code=exited, status=0/SUCCESS)
  • 4.运行:sudo nginx -t
  • 4.结果:
nginx: [emerg] open() "/etc/nginx/sites-enabled/myproject" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed
    1. 否则 Nginex 应该没问题,因为网站上的 html 加载并运行良好。这个堆栈溢出帖子说我也许应该对安全性做一些事情,nginx.conf但在那种情况下,他们谈论的是一个 worldpres 网站,所以我不知道如何在这里实现它。
    1. 我之前尝试过这个堆栈溢出帖子的答案,下面是它有一个子帖子来进一步配置 RUN 的答案:sudo nginx -c /etc/nginx/sites-enabled/default -t
  • 6.结果:
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-enabled/default:21
nginx: configuration file /etc/nginx/sites-enabled/default test failed
python nginx django 18.04
  • 1 个回答
  • 1006 Views
Martin Hope
sogu
Asked: 2020-03-25 11:26:52 +0800 CST

启动 gunicorn.service 失败:未找到单元 gunicorn.service。乌本托 18.04

  • 1

我正在关注如何在 Ubuntu 18.04 指南上使用 Postgres、Nginx 和 Gunicorn 设置 Django。

我创建了以下文件 .socket

sudo nano /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

我创建了以下文件 .service

sudo nano /etc/systemd/system/gunicorn.service

指南中的原始 RECOMENDED_FORMATTING-s

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target


[Service]
User=sammyRECOMENDED_FORMATTING
Group=www-data
WorkingDirectory=/home/sammyRECOMENDED_FORMATTING/myprojectdirRECOMENDED_FORMATTING
ExecStart=/home/sammyRECOMENDED_FORMATTING/myprojectdirRECOMENDED_FORMATTING/myprojectenvRECOMENDED_FORMATTING/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          myprojectRECOMENDED_FORMATTING.wsgi:application

[Install]
WantedBy=multi-user.target

我如何格式化我自己的版本我在服务器上的项目文件夹之外拥有我的虚拟环境

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=SERVER_USER
Group=www-data
WorkingDirectory=/home/SERVER_USER/MAIN_PROJECT_FOLDER
ExecStart=/home/SERVER_USER/ven/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/home/SERVER_USER/MAIN_PROJECT_FOLDER/MAINAPPLICATION_FOLDER.sock \
          MAINAPPLICATION_FOLDER.wsgi:application

[Install]
WantedBy=multi-user.target

我也尝试过按照最初的建议保留这些

--bind unix:/run/gunicorn.sock \

比我尝试执行以下代码

sudo systemctl start gunicorn

错误信息 1

Failed to start gunicorn.service: Unit gunicorn.service not found.

我也试过2

sudo systemctl start gunicorn.socket

错误信息 2

Failed to start gunicorn.socket: Unit gunicorn.socket is not loaded properly: Invalid argument.
See system logs and 'systemctl status gunicorn.socket' for details.

为了解决这个问题,我尝试过

  • https://stackoverflow.com/questions/40711747/failed-to-start-gunicorn-service-unit-gunicorn-service-not-found这指向了我正在做的完全相同的指南,除了旧版本的 linux .
  • 这不是相同的代码并且没有回答Unit gunicorn.service failed to load: No such file or directory
  • 运行:systemctl status gunicorn.socket结果:Warning: The unit file, source configuration file or drop-ins of gunicorn.socket changed on disk ● gunicorn.socket - gunicorn daemon Loaded: error (Reason: Invalid argument) Active: inactive (dead)
  • 运行:systemctl is-enabled gunicorn.socket结果:enabled
  • 运行:systemctl is-enabled gunicorn.service结果:Failed to get unit file state for gunicorn.service: No such file or directory
18.04
  • 2 个回答
  • 11993 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve