微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

具有django和django-extensions的PyInstaller

如何解决具有django和django-extensions的PyInstaller

我正在尝试使用PyInstaller使用django构建可执行文件,并使用django-extensions库使用'runserver_plus'。

使用

django==1.11
PyInstaller==3.4
django-extensions==2.2.1

添加到settings.py文件中,

INSTALLED_APPS = (
    ...
    'django_extensions',)

在Django的PyInstaller加载程序文件中,

PyInstaller\loader\rthooks\pyi_rth_django.py

import django.core.management
import django.utils.autoreload

def _get_commands():
    # Django groupss commands by app.
    # This returns static dict() as it is for django 1.8 and the default project.
    commands = {
         'changepassword': 'django.contrib.auth','check': 'django.core','clearsessions': 'django.contrib.sessions','collectstatic': 'django.contrib.staticfiles','compilemessages': 'django.core','createcachetable': 'django.core','createsuperuser': 'django.contrib.auth','dbshell': 'django.core','diffsettings': 'django.core','dumpdata': 'django.core','findstatic': 'django.contrib.staticfiles','flush': 'django.core','inspectdb': 'django.core','loaddata': 'django.core','makemessages': 'django.core','makemigrations': 'django.core','migrate': 'django.core','runfcgi': 'django.core','runserver': 'django.core','runserver_plus':'django_extensions','shell': 'django.core','showmigrations': 'django.core','sql': 'django.core','sqlall': 'django.core','sqlclear': 'django.core','sqlcustom': 'django.core','sqldropindexes': 'django.core','sqlflush': 'django.core','sqlindexes': 'django.core','sqlmigrate': 'django.core','sqlsequencereset': 'django.core','squashmigrations': 'django.core','startapp': 'django.core','startproject': 'django.core','syncdb': 'django.core','test': 'django.core','testserver': 'django.core','validate': 'django.core'
    }
    return commands

为Django项目创建可执行文件后。在这种情况下,“ runserver”运行顺利。 使用PyInstaller构建可执行文件后,无法使用'runserver_plus'命令。

ubuntu@ubuntu:~/executables$ ./dist/myproject/myproject runserver_plus
 * Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
 * Restarting with stat
UnkNown command: '/home/ubuntu/executables/dist/myproject/myproject'
Type 'myproject help' for usage.
ubuntu@ubuntu:~/executables$ 

执行后,

ubuntu@ubuntu:~/executables$ ./dist/myproject/myproject help

Type 'myproject help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    runfcgi
    runserver
    shell
    showmigrations
    sql
    sqlall
    sqlclear
    sqlcustom
    sqldropindexes
    sqlflush
    sqlindexes
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    syncdb
    test
    testserver
    validate

[django_extensions]
    runserver_plus

[sessions]
    clearsessions

[sslserver]
    runsslserver

[staticfiles]
    collectstatic
    findstatic
ubuntu@ubuntu:~/executables$

如何使用PyInstaller使用django-extensions库为django构建可执行文件

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?