python importlib bootstrap_python

在尝试使用PyInstaller将Django项目编译成exe时遇到问题,错误提示涉及GDAL库找不到。编译过程中,Django的某些模块如`django.contrib.gis`在寻找GDAL依赖时失败。最终在运行exe时,出现`No module named 'django_admin_select2'`的错误。已经安装的插件包括Django、django-admin-select2等。
摘要由CSDN通过智能技术生成

我正在尝试使用PyInstaller编译django项目,因为共享磁盘驱动程序中的安全性使每个人都可以查看我的代码。

当编译时,我得到以下输出:

(env)D:__ DEV __> pyinstaller Chortke / manage.py --onedir

222 INFO: PyInstaller: 4.0.dev0+46286a1f4

222 INFO: Python: 3.7.4 (conda)

222 INFO: Platform: Windows-10-10.0.16299-SP0

222 INFO: wrote D:\__DEV__\manage.spec

222 INFO: UPX is not available.

239 INFO: Extending PYTHONPATH with paths

['D:\\__DEV__\\Chortke', 'D:\\__DEV__']

239 INFO: checking Analysis

239 INFO: Building Analysis because Analysis-00.toc is non existent

239 INFO: Initializing module dependency graph...

244 INFO: Caching module graph hooks...

256 INFO: Analyzing base_library.zip ...

6561 INFO: Caching module dependency graph...

6664 INFO: running Analysis Analysis-00.toc

6679 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable

required by c:\users\mab\.conda\envs\env\python.exe

7249 INFO: Analyzing D:\__DEV__\Chortke\manage.py

7307 INFO: Processing pre-find module path hook distutils

7311 INFO: distutils: retargeting to non-venv dir 'c:\\users\\mab\\.conda\\envs\\env\\lib'

8887 INFO: Processing pre-find module path hook site

8887 INFO: site: retargeting to fake-dir 'c:\\users\\mab\\.conda\\envs\\env\\lib\\site-packages\\PyInstaller\\fake-modules'

15264 INFO: Processing module hooks...

15264 INFO: Loading module hook "hook-distutils.py"...

15264 INFO: Loading module hook "hook-django.core.cache.py"...

15439 INFO: Loading module hook "hook-django.core.mail.py"...

15601 INFO: Loading module hook "hook-django.core.management.py"...

15634 INFO: Import to be excluded not found: 'tkinter'

15635 INFO: Import to be excluded not found: 'IPython'

15635 INFO: Import to be excluded not found: 'matplotlib'

15635 INFO: Loading module hook "hook-django.db.backends.py"...

17084 WARNING: Hidden import "django.db.backends.__pycache__.base" not found!

17084 INFO: Loading module hook "hook-django.py"...

Traceback (most recent call last):

File "", line 41, in

File "", line 36, in walk_packages

File "", line 36, in walk_packages

File "", line 20, in walk_packages

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in

from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in

from django.contrib.gis.admin.widgets import OpenLayersWidget

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\widgets.py", line 3, in

from django.contrib.gis.gdal import GDALException

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in

from django.contrib.gis.gdal.datasource import DataSource

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in

from django.contrib.gis.gdal.driver import Driver

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in

from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in

from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 43, in

% '", "'.join(lib_names)

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal203", "gdal202", "gdal201", "gdal20", "gdal111"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

19403 INFO: Determining a mapping of distributions to packages...

24054 INFO: Packages required by django:

['sqlparse', 'pytz']

24054 INFO: Django root directory D:\__DEV__\Chortke\chortke

Traceback (most recent call last):

File "c:\users\mab\.conda\envs\env\lib\site-packages\PyInstaller\utils\hooks\subproc\django_import_finder.py", line 37, in

list(settings.TEMPLATE_LOADERS) + \

File "c:\users\mab\.conda\envs\env\lib\site-packages\django\conf\__init__.py", line 80, in __getattr__

val = getattr(self._wrapped, name)

AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'

25398 INFO: Collecting Django migration scripts.

31358 INFO: Loading module hook "hook-encodings.py"...

31458 INFO: Loading module hook "hook-PIL.Image.py"...

32433 INFO: Loading module hook "hook-PIL.py"...

32433 INFO: Excluding import 'PySide'

32433 INFO: Removing import of PySide from module PIL.ImageQt

32449 INFO: Excluding import 'PyQt4'

32452 INFO: Removing import of PyQt4 from module PIL.ImageQt

32452 INFO: Excluding import 'PyQt5'

32454 INFO: Removing import of PyQt5 from module PIL.ImageQt

32455 INFO: Excluding import 'tkinter'

32458 INFO: Removing import of tkinter from module PIL.ImageTk

32458 INFO: Import to be excluded not found: 'FixTk'

32458 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...

32460 INFO: Excluding import 'tkinter'

32462 INFO: Import to be excluded not found: 'FixTk'

32462 INFO: Loading module hook "hook-pkg_resources.py"...

32934 INFO: Processing pre-safe import module hook win32com

Traceback (most recent call last):

File "", line 2, in

ModuleNotFoundError: No module named 'win32com'

33011 INFO: Processing pre-safe import module hook win32com

Traceback (most recent call last):

File "", line 2, in

ModuleNotFoundError: No module named 'win32com'

33134 INFO: Excluding import '__main__'

33136 INFO: Removing import of __main__ from module pkg_resources

33136 INFO: Loading module hook "hook-pydoc.py"...

33137 INFO: Loading module hook "hook-pytz.py"...

33208 INFO: Loading module hook "hook-sqlite3.py"...

33307 INFO: Loading module hook "hook-sysconfig.py"...

33307 INFO: Loading module hook "hook-xml.dom.domreg.py"...

33307 INFO: Loading module hook "hook-xml.py"...

33307 INFO: Loading module hook "hook-_tkinter.py"...

33579 INFO: checking Tree

33579 INFO: Building Tree because Tree-00.toc is non existent

33579 INFO: Building Tree Tree-00.toc

33663 INFO: checking Tree

33663 INFO: Building Tree because Tree-01.toc is non existent

33663 INFO: Building Tree Tree-01.toc

33683 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...

33697 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...

33806 INFO: Looking for ctypes DLLs

33894 INFO: Analyzing run-time hooks ...

33900 INFO: Including run-time hook 'pyi_rth_pkgres.py'

33901 INFO: Including run-time hook 'pyi_rth_django.py'

33907 INFO: Looking for dynamic libraries

34271 INFO: Looking for eggs

34271 INFO: Using Python library c:\users\mab\.conda\envs\env\python37.dll

34271 INFO: Found binding redirects:

[]

34271 INFO: Warnings written to D:\__DEV__\build\manage\warn-manage.txt

34435 INFO: Graph cross-reference written to D:\__DEV__\build\manage\xref-manage.html

34710 INFO: checking PYZ

34710 INFO: Building PYZ because PYZ-00.toc is non existent

34710 INFO: Building PYZ (ZlibArchive) D:\__DEV__\build\manage\PYZ-00.pyz

35823 INFO: Building PYZ (ZlibArchive) D:\__DEV__\build\manage\PYZ-00.pyz completed successfully.

35874 INFO: checking PKG

35875 INFO: Building PKG because PKG-00.toc is non existent

35875 INFO: Building PKG (CArchive) PKG-00.pkg

35896 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.

35904 INFO: Bootloader c:\users\mab\.conda\envs\env\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe

35904 INFO: checking EXE

35904 INFO: Building EXE because EXE-00.toc is non existent

35905 INFO: Building EXE from EXE-00.toc

35905 INFO: Appending archive to EXE D:\__DEV__\build\manage\manage.exe

36000 INFO: Building EXE from EXE-00.toc completed successfully.

36014 INFO: checking COLLECT

36015 INFO: Building COLLECT because COLLECT-00.toc is non existent

36015 INFO: Building COLLECT COLLECT-00.toc

134331 INFO: Building COLLECT COLLECT-00.toc completed successfully.

当我运行exe文件时,出现此错误:

(env)D:__ DEV __> dist \\ manage \\ manage.exe运行服务器

Watching for file changes with StatReloader

Exception in thread django-main-thread:

Traceback (most recent call last):

File "threading.py", line 926, in _bootstrap_inner

File "threading.py", line 870, in run

File "site-packages\django\utils\autoreload.py", line 54, in wrapper

File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 109, in inner_run

autoreload.raise_last_exception()

File "site-packages\django\utils\autoreload.py", line 77, in raise_last_exception

File "site-packages\django\core\management\__init__.py", line 337, in execute

File "site-packages\django\utils\autoreload.py", line 54, in wrapper

File "site-packages\django\__init__.py", line 24, in setup

File "site-packages\django\apps\registry.py", line 91, in populate

File "site-packages\django\apps\config.py", line 90, in create

File "importlib\__init__.py", line 127, in import_module

File "", line 1006, in _gcd_import

File "", line 983, in _find_and_load

File "", line 965, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'django_admin_select2'

Traceback (most recent call last):

File "manage.py", line 15, in

File "site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line

File "site-packages\django\core\management\__init__.py", line 375, in execute

File "site-packages\django\core\management\base.py", line 323, in run_from_argv

File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 60, in execute

super().execute(*args, **options)

File "site-packages\django\core\management\base.py", line 364, in execute

File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 95, in handle

self.run(**options)

File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 102, in run

autoreload.run_with_reloader(self.inner_run, **options)

File "site-packages\django\utils\autoreload.py", line 598, in run_with_reloader

File "site-packages\django\utils\autoreload.py", line 583, in start_django

File "site-packages\django\utils\autoreload.py", line 301, in run

File "site-packages\django\utils\autoreload.py", line 307, in run_loop

File "site-packages\django\utils\autoreload.py", line 347, in tick

File "site-packages\django\utils\autoreload.py", line 363, in snapshot_files

File "site-packages\django\utils\autoreload.py", line 262, in watched_files

File "site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files

File "site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files

File "pathlib.py", line 1346, in exists

File "pathlib.py", line 1168, in stat

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ''

[5108] Failed to execute script manage

已安装的插件:

(env)D:__ DEV __>点冻结

altgraph==0.16.1

astroid==2.2.5

backports.csv==1.0.7

certifi==2019.6.16

colorama==0.4.1

defusedxml==0.6.0

diff-match-patch==20181111

Django==2.2.4

django-admin-rangefilter==0.5.0

django-admin-select2==1.0.1

django-import-export==1.2.0

django-jalali==3.1.0

django-modeladmin-reorder==0.3.1

django-nested-admin==3.2.3

et-xmlfile==1.0.1

Faker==1.0.7

future==0.17.1

isort==4.3.21

jdatetime==3.2.0

jdcal==1.4.1

lazy-object-proxy==1.4.1

mccabe==0.6.1

odfpy==1.4.0

openpyxl==2.6.2

pefile==2019.4.18

Pillow==6.1.0

PyInstaller==4.0.dev0+46286a1f4

pylint==2.3.1

python-dateutil==2.8.0

python-monkey-business==1.0.0

pytz==2019.2

pywin32-ctypes==0.2.0

PyYAML==5.1.2

six==1.12.0

sqlparse==0.3.0

tablib==0.13.0

text-unidecode==1.2

typed-ast==1.4.0

wincertstore==0.2

wrapt==1.11.2

xlrd==1.2.0

xlwt==1.3.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值