Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7588425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:55:00+00:00 2026-05-30T19:55:00+00:00

I am trying to compile a python script using pyinstaller with modules like scientific,MMTK.

  • 0

I am trying to compile a python script using pyinstaller with modules like scientific,MMTK. Pyinstaller was unable to include some .pyd modules so I copied them manually in the dist folder. When I executed the compiled exe it gave me following error:-

C:\Python27\hello\dist\hello>hello.exe
Traceback (most recent call last):
  File "", line 21, in 
  File "C:\Python27\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Python27\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/visual", line 1, in <module>
  File "C:\Python27\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Python27\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/visual.visual_all", line 1, in <module>
  File "C:\Python27\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Python27\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis", line 13, in <module>
  File "C:\Python27\iu.py", line 436, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Python27\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.ui", line 3, in <module>
  File "C:\Python27\iu.py", line 477, in importHook
    mod = self.doimport(nm, ctx, ctx+'.'+nm)
  File "C:\Python27\iu.py", line 521, in doimport
    exec co in mod.__dict__
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.materials", line 159, in <module>
  File "c:\Python27\hello\build\pyi.win32\hello\outPYZ1.pyz/vis.materials", line 129, in loadTGA
IOError: [Errno 2] No such file or directory: 'c:\\Python27\\hello\\build\\pyi.win32\\hello\\outPYZ1.pyz/turbulence3.tga'

BTW I can see the outPYZ1.pyz file at that location. Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:55:02+00:00Added an answer on May 30, 2026 at 7:55 pm

    It’s not about pyd files, but about a TGA file not found. You need to adapt your software to look at a different location when the application is packaged by pyinstaller. According to Accessing to data files:

    In a –onedir distribution, this is easy: pass a list of your data
    files (in TOC format) to the COLLECT, and they will show up in the
    distribution directory tree. The name in the (name, path, ‘DATA’)
    tuple can be a relative path name. Then, at runtime, you can use code
    like this to find the file:

    os.path.join(os.path.dirname(sys.executable), relativename))
    

    In a
    –onefile distribution, data files are bundled within the executable and then extracted at runtime into the work directory by the C code
    (which is also able to reconstruct directory trees). The work
    directory is best found by os.environ[‘_MEIPASS2’]. So, you can access
    those files through:

    os.path.join(os.environ["_MEIPASS2"], relativename))
    

    So, if you open a file in your program, don’t do:

    fd = open('myfilename.tga', 'rb')
    

    This method is opening the file from the current directory. So it will just not work for pyinstaller, because the current directory will be not the same than where the data will be put.

    Depending if you are using --onefile, you must change to:

    import os
    filename = 'myfilename.tga' 
    if '_MEIPASS2' in os.environ:
        filename = os.path.join(os.environ['_MEIPASS2'], filename))
    fd = open(filename, 'rb')
    

    Or if it’s --onedir:

    import os, sys
    filename = os.path.join(os.path.dirname(sys.executable), 'myfilename.tga'))
    fd = open(filename, 'rb')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile my python script into a single .exe using gui2exe (which
I'm trying to compile a Python binding, but I'm unable to find the python.h
I'm trying to compile to an exe my script of python, but I'm getting
I am trying to compile a simple script I wrote using Python3 and PyQt4
I'm trying to compile a python script. On executing the exe I got:- C:\Python27\dist>visualn.exe
I'm trying to compile python source code foo.py to C using cython . In
I am currently writing a Python script and trying to dynamically generate some arguments.
I'm trying to run a python script using python 2.6.4. The hosting company has
I am trying to implement a function in my Python script to compile a
I'm trying to compile Vim 7.2 with Python 2.5.1 support, but I'm having some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.