简体   繁体   中英

PyInstaller : 'no module named os.path'

I'm trying to compile a code named 'interface.py' with PyInstaller. Everything goes fine during the compilation but when I try to launch 'interface.exe' I get this error:

    [INFO   ] [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_19.txt
[INFO   ] [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_19.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
 Traceback (most recent call last):
   File "C:\Users\Samuel\Documents\PycharmProjects\Zernik\interface.py", line 8, in <module>
     from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
   File "c:\users\samuel\appdata\local\temp\pip-build-pp0wwt\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
   File "C:\Python27\lib\site-packages\kivy\garden\__init__.py", line 68, in <module>
     from os.path import dirname, join, realpath, exists, abspath
   File "c:\users\samuel\appdata\local\temp\pip-build-pp0wwt\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 161, in load_module
   File "c:\users\samuel\appdata\local\temp\pip-build-pp0wwt\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
   File "C:\Python27\lib\os.py", line 120, in <module>
     from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
 ImportError: No module named path
[11308] Failed to execute script interface

In 'interface.py' these are the modules I import:

import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.popup import Popup
from kivy.uix.filechooser import FileChooserIconView
from kivy.properties import ObjectProperty
from kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg
import matplotlib.pyplot as plt

import opticspy.zernike as oz
import numpy as np
import xlrd

And I use matplotlib in opticspy.zernike. I tried to import os.path in 'interface.py' but it didn't worked. I think the error comes from the kivy.garden.matplotlib module because before I use it, it worked fine.

Do you know what I'm doing wrong ?

Thank you for your help

Finally, I solved my problem by completely uninstall python from my computer. Then I re-install python 3 (rather than python 2 that I had) and now it works. It seems that python 3 works better than python 2 for this.

Thank you for your help. I hope you didn't spent too much time on this issue.

Sorry but i can't write at comments. Try : sys.path.insert(0,'C:/Python27/lib') before importing os as it seems this module somehow changes your sys path, or if it still fails try import os before all other modules. Also you can print sys.path at another test script to see witch is the correct sys.path and add it. Hope this helps.

I do not understand why my interface.exe use python from C:/python27, whereas It should create a standalone package ? Also I have some issues during my compilation :

203 INFO: PyInstaller: 3.3.1
203 INFO: Python: 2.7.14
218 INFO: Platform: Windows-10-10.0.16299
218 INFO: UPX is not available.
[INFO   ] [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_104.txt
234 INFO: [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_104.txt
[INFO   ] [Kivy        ] v1.10.0
234 INFO: [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
250 INFO: [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
250 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Samuel\\Documents\\PycharmProjects\\Zernik',
 'C:\\Users\\Samuel\\Documents\\PycharmProjects\\Zernik']
250 INFO: checking Analysis
250 INFO: Building Analysis because out00-Analysis.toc is non existent
250 INFO: Initializing module dependency graph...
250 INFO: Initializing module graph hooks...
312 INFO: running Analysis out00-Analysis.toc
312 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
  required by C:\Python27\python.exe
406 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
406 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
406 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_f47b3af6f659a4cf.manifest
484 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9317_none ...
500 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_508dca76bcbcfe81.manifest
500 INFO: Searching for file msvcr90.dll
500 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_508dca76bcbcfe81\msvcr90.dll
500 INFO: Searching for file msvcp90.dll
500 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_508dca76bcbcfe81\msvcp90.dll
500 INFO: Searching for file msvcm90.dll
500 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_508dca76bcbcfe81\msvcm90.dll
577 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
577 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
592 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_f47b3af6f659a4cf.manifest
592 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9317)
703 INFO: Caching module hooks...
708 INFO: Analyzing interface.py
2184 INFO: Processing pre-find module path hook   distutils
2977 INFO: Processing pre-safe import module hook   _xmlplus
5824 INFO: Processing pre-safe import module hook   six.moves
8948 INFO: Processing pre-find module path hook   site
8949 INFO: site: retargeting to fake-dir 'C:\\Python27\\lib\\site-packages\\PyInstaller\\fake-modules'
16363 INFO: Loading module hooks...
16363 INFO: Loading module hook "hook-distutils.py"...
16363 INFO: Loading module hook "hook-sysconfig.py"...
16363 INFO: Loading module hook "hook-xml.py"...
16363 INFO: Loading module hook "hook-pycparser.py"...
16638 INFO: Loading module hook "hook-httplib.py"...
16639 INFO: Loading module hook "hook-pydoc.py"...
16641 INFO: Excluding import 'Tkinter'
16643 INFO:   Removing import of Tkinter from module pydoc
16644 INFO: Loading module hook "hook-kivy.py"...
[INFO   ] [Factory     ] 194 symbols loaded
16648 INFO: [Factory     ] 194 symbols loaded
[INFO   ] [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_105.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO   ] [Logger      ] Record log in C:\Users\Samuel\.kivy\logs\kivy_18-01-26_106.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]
[INFO   ] [Audio       ] Providers: audio_sdl2 (audio_ffpyplayer ignored)
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[CRITICAL] [Camera      ] Unable to find any valuable Camera provider.
opencv - ImportError: No module named cv2
  File "C:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Python27\lib\site-packages\kivy\core\camera\camera_opencv.py", line 45, in <module>
    import cv2

[INFO   ] [Clipboard   ] Provider: winctypes
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <4.5.0 - Build 22.20.16.4836>
[INFO   ] [GL          ] OpenGL vendor <Intel>
[INFO   ] [GL          ] OpenGL renderer <Intel(R) HD Graphics 630>
[INFO   ] [GL          ] OpenGL parsed version: 4, 5
[INFO   ] [GL          ] Shading version <4.50 - Build 22.20.16.4836>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Shader      ] fragment shader: <WARNING: 0:4: '' :  #version directive missing>
[INFO   ] [Shader      ] vertex shader: <WARNING: 0:4: '' :  #version directive missing>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[CRITICAL] [Spelling    ] Unable to find any valuable Spelling provider.
enchant - ImportError: No module named enchant
  File "C:\Python27\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Python27\lib\site-packages\kivy\core\spelling\spelling_enchant.py", line 6, in <module>
    import enchant

[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Video       ] Provider: null(['video_ffmpeg', 'video_ffpyplayer'] ignored)
20049 INFO: Excluding import 'Tkinter'
20064 INFO: Excluding import 'twisted'
20064 INFO:   Removing import of twisted from module kivy.support
20064 INFO: Excluding import '_tkinter'
20080 INFO: Loading module hook "hook-_tkinter.py"...
20221 INFO: checking Tree
20221 INFO: Building Tree because out00-Tree.toc is non existent
20221 INFO: Building Tree out00-Tree.toc
20392 INFO: checking Tree
20392 INFO: Building Tree because out01-Tree.toc is non existent
20392 INFO: Building Tree out01-Tree.toc
20424 INFO: Loading module hook "hook-docutils.py"...
21881 INFO: Loading module hook "hook-matplotlib.backends.py"...
22335 INFO:   Matplotlib backend "GTK": ignored
    Gtk* backend requires pygtk to be installed.
22679 INFO:   Matplotlib backend "GTKAgg": ignored
    Gtk* backend requires pygtk to be installed.
22950 INFO:   Matplotlib backend "GTKCairo": ignored
    No module named gtk
23277 INFO:   Matplotlib backend "MacOSX": ignored
    cannot import name _macosx
23621 INFO:   Matplotlib backend "Qt4Agg": ignored
    Matplotlib qt-based backends require an external PyQt4, PyQt5,
PySide or PySide2 package to be installed, but it was not found.
24093 INFO:   Matplotlib backend "Qt5Agg": ignored
    Matplotlib qt-based backends require an external PyQt4, PyQt5,
PySide or PySide2 package to be installed, but it was not found.
24485 INFO:   Matplotlib backend "TkAgg": added
24926 INFO:   Matplotlib backend "WX": ignored
    Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12
25351 INFO:   Matplotlib backend "WXAgg": ignored
    Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12
25656 INFO:   Matplotlib backend "GTK3Cairo": ignored
    Cairo backend requires that cairocffi or pycairo is installed.
26123 INFO:   Matplotlib backend "GTK3Agg": ignored
    Gtk3 backend requires pygobject to be installed.
26353 INFO:   Matplotlib backend "WebAgg": ignored
    Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_webagg.py", line 31, in <module>
    raise RuntimeError("The WebAgg backend requires Tornado.")
RuntimeError: The WebAgg backend requires Tornado.
26606 INFO:   Matplotlib backend "nbAgg": ignored
    No module named tornado.ioloop
26965 INFO:   Matplotlib backend "agg": added
27213 INFO:   Matplotlib backend "cairo": ignored
    Cairo backend requires that cairocffi or pycairo is installed.
27461 INFO:   Matplotlib backend "gdk": ignored
    No module named gobject
27810 INFO:   Matplotlib backend "pdf": added
28277 INFO:   Matplotlib backend "pgf": added
28648 INFO:   Matplotlib backend "ps": added
29013 INFO:   Matplotlib backend "svg": added
29365 INFO:   Matplotlib backend "template": added
29562 INFO: Loading module hook "hook-matplotlib.py"...
29829 INFO: Loading module hook "hook-xml.dom.domreg.py"...
29829 INFO: Loading module hook "hook-pkg_resources.py"...
30123 INFO: Processing pre-safe import module hook   win32com
30444 INFO: Loading module hook "hook-pytz.py"...
30531 INFO: Loading module hook "hook-pywintypes.py"...
30773 INFO: Loading module hook "hook-setuptools.py"...
30814 INFO: Loading module hook "hook-encodings.py"...
31319 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
31319 INFO: Loading module hook "hook-numpy.core.py"...
31379 INFO: Loading module hook "hook-win32com.py"...
31878 INFO: Loading module hook "hook-pythoncom.py"...
32120 INFO: Loading module hook "hook-pygments.py"...
33836 INFO: Looking for ctypes DLLs
33928 INFO: Analyzing run-time hooks ...
33944 INFO: Including run-time hook 'pyi_rth__tkinter.py'
33944 INFO: Including run-time hook 'pyi_rth_pkgres.py'
33944 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
33944 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
33960 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
33960 INFO: Including run-time hook 'pyi_rth_mpldata.py'
33960 INFO: Including run-time hook 'pyi_rth_kivy.py'
33960 INFO: Including run-time hook 'pyi_rth_gstreamer.py'
33975 INFO: Looking for dynamic libraries
34261 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_ecff360cfb2594f3.manifest
34355 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.4148_none ...
34355 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7.manifest
34355 INFO: Searching for file mfc90.dll
34355 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7\mfc90.dll
34355 INFO: Searching for file mfc90u.dll
34355 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7\mfc90u.dll
34355 INFO: Searching for file mfcm90.dll
34355 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7\mfcm90.dll
34355 INFO: Searching for file mfcm90u.dll
34355 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7\mfcm90u.dll
34450 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_ecff360cfb2594f3.manifest
34452 INFO: Adding redirect Microsoft.VC90.MFC version (9, 0, 21022, 8) -> (9, 0, 30729, 4148)
35236 WARNING: lib not found: libglib-2.0-0.dll dependency of C:\Python27\lib\site-packages\kivy\lib\gstplayer\_gstplayer.pyd
35312 WARNING: lib not found: libgstreamer-1.0-0.dll dependency of C:\Python27\lib\site-packages\kivy\lib\gstplayer\_gstplayer.pyd
35375 WARNING: lib not found: libgobject-2.0-0.dll dependency of C:\Python27\lib\site-packages\kivy\lib\gstplayer\_gstplayer.pyd
47240 INFO: Looking for eggs
47240 INFO: Using Python library C:\Windows\system32\python27.dll
47241 INFO: Found binding redirects:
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9317), publicKeyToken=u'1fc8b3b9a1e18e3b'), BindingRedirect(name=u'Microsoft.VC90.MFC', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 4148), publicKeyToken=u'1fc8b3b9a1e18e3b')]
47253 INFO: Warnings written to C:\Users\Samuel\Documents\PycharmProjects\Zernik\build\interface\warninterface.txt
47436 INFO: Graph cross-reference written to C:\Users\Samuel\Documents\PycharmProjects\Zernik\build\interface\xref-interface.html
47987 INFO: checking PYZ
47987 INFO: Building PYZ because out00-PYZ.toc is non existent
47987 INFO: Building PYZ (ZlibArchive) C:\Users\Samuel\Documents\PycharmProjects\Zernik\build\interface\out00-PYZ.pyz
50438 INFO: Building PYZ (ZlibArchive) C:\Users\Samuel\Documents\PycharmProjects\Zernik\build\interface\out00-PYZ.pyz completed successfully.
50654 INFO: checking PKG
50671 INFO: Building PKG because out00-PKG.toc is non existent
50671 INFO: Building PKG (CArchive) out00-PKG.pkg
50701 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
50701 INFO: Bootloader C:\Python27\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
50701 INFO: checking EXE
50701 INFO: Building EXE because out00-EXE.toc is non existent
50701 INFO: Building EXE from out00-EXE.toc
50701 INFO: Appending archive to EXE C:\Users\Samuel\Documents\PycharmProjects\Zernik\build\interface\interface.exe
50717 INFO: Building EXE from out00-EXE.toc completed successfully.
50732 INFO: checking Tree
50732 INFO: Building Tree because out02-Tree.toc is non existent
50732 INFO: Building Tree out02-Tree.toc
50732 INFO: checking Tree
50732 INFO: Building Tree because out03-Tree.toc is non existent
50732 INFO: Building Tree out03-Tree.toc
50748 INFO: checking Tree
50748 INFO: Building Tree because out04-Tree.toc is non existent
50748 INFO: Building Tree out04-Tree.toc
50748 INFO: checking COLLECT
50748 INFO: Building COLLECT because out00-COLLECT.toc is non existent
50764 INFO: Building COLLECT out00-COLLECT.toc
50779 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9317)
57274 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

(Sorry for this long log)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM