Python 带有django和django扩展的PyInstaller
我正在尝试使用PyInstaller和django扩展库使用“runserver_plus”构建django可执行文件 使用Python 带有django和django扩展的PyInstaller,python,django,pyinstaller,django-extensions,Python,Django,Pyinstaller,Django Extensions,我正在尝试使用PyInstaller和django扩展库使用“runserver_plus”构建django可执行文件 使用 django==1.11 PyInstaller==3.4 django-extensions==2.2.1 在settings.py文件中添加 INSTALLED_APPS = ( ... 'django_extensions', ) 在django的PyInstaller加载程序文件中 PyInstaller\loader\rthooks\pyi_
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\u 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$
ubuntu@ubuntu:~/executables$。/dist/myproject/myproject帮助
键入“myproject帮助”以获取有关特定子命令的帮助。
可用子命令:
[授权]
更改密码
创建超级用户
[django]
检查
编译消息
createcachetable
dbshell
扩散设置
转储数据
脸红
检查数据库
加载数据
制造信息
makemigration
迁移
runfcgi
运行服务器
壳
展示迁移
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlmigrate
sqlsequencereset
挤压迁移
startapp
启动项目
同步数据库
测试
测试服务器
验证
[django_扩展]
runserver_plus
[会议]
清除
[sslserver]
运行服务器
[静态文件]
收集静电
findstatic
ubuntu@ubuntu:~/可执行文件$
如何使用PyInstaller为django构建带有django扩展库的可执行文件