473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[pyinstaller] how to compile Python script importing module

Hi,

I need to compile a pyhton tool into an executable as the destination plateform (Solaris, Linux) are not deployed with Python or not all needed modules.

I found pyinstaller and follow the classical tutorial.

First executable starts correctly under Linux but not under windows.

Second it crashes right after due to unknown module that haev to be loaded.

Here is a view of my tool. The following code comes from analyzer.py I have to call to run this tool.

Expand|Select|Wrap|Line Numbers
  1. try:
  2.     TOOLS_ROOT = os.environ['TOOLS_ROOT']
  3.     sys.path.append(TOOLS_ROOT)
  4. except KeyError:
  5.     print 'TOOLS_ROOT is undefined. Please set it.'
  6.     sys.exit(1)
  7.  
  8. import lib.globals
  9. from lib.parserLib import Architecture
  10. import thread
  11. import threading
  12. ...
  13.  
here is directory architecture

/tool/__init__.py
analyzer.py
lib/__init__.py
globals.py
parserLib.py
Few questions:

- how to bypass the TOOLS_ROOT env var decalaration, that I used when I run directly analyzer.py under linux ?
Here is output of the script if I do not declare this ver
"""
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
TOOLS_ROOT is undefined. Please set it.
vmintegration:~/pyinstaller-1.4/analyzer#
"""

- how to indicate to pyinstaller that modules have to be included into the executable file, because they are currently not recognized
Here is output of the script when TOOLS_ROOT is defined (with a fake value)
"""
vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=`pwd`
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
Traceback (most recent call last):
File "<string>", line 21, in <module>
File "/root/pyinstaller-1.4/iu.py", line 455, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named lib
"""

- how to integrate argument from command line if I need ?
Here is output of the script if TOOLS_ROOT is defined to the "real" root of my tool
"""
vmintegration:~/pyinstaller-1.4/analyzer# export TOOLS_ROOT=/home/stephane/tool
vmintegration:~/pyinstaller-1.4/analyzer# ./dist/analyzer
ERROR : Arg <opt> missing in command line ****
"""



I attached warnlog file to help me.



Here is the spec content file
"""
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), '/home/stephane/python/script/analyzer.py'],
pathex=['/root/pyinstaller-1.4'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'analyzer'),
debug=False,
strip=False,
upx=True,
console=1 )
"""



Thanks for any help.
I read some documentation about pyinstaller but it's not very clear for me and I'm not able to progress anynmore.

Regards
Attached Files
File Type: txt warnanalyzer.txt (2.3 KB, 395 views)
Apr 19 '11 #1
0 1767

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tubby Tudor | last post by:
What is the best way to call one python script from within another python script? For example: one.py finishes succesfully and calls two.py which finishes OK and then calls three.py Thanks...
5
by: Shalen chhabra | last post by:
Hey, Can anyone give me a snippet for running a python program over all the files in the directory. For ex: I have ten files in a directory and I want to run a python program against all of...
8
by: mrstephengross | last post by:
I want to find a way to embed a tar file *in* my python script, and then use the tarfile module to extract it. That is, instead of distributing two files (extractor.py and archive.tar) I want to be...
0
by: phoolimin | last post by:
Dear all, I am trying to embed python into another scripting language, to do this I need to solve a number of problems on importing or compiling python script. First let me state what exactly I...
14
by: mistral | last post by:
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows.
2
by: Viewer T. | last post by:
I am trying to write a script that deletes certain files based on certain criteria. What I am trying to do is to automate the process of deleting certain malware files that disguise themselves...
4
by: bluegray | last post by:
I'm writing a script that outputs html. It works fine in Firefox, however, IE wants to download the file instead of displaying the output. I keep getting the file download dialog instead of the...
4
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application....
3
by: bsagert | last post by:
I downloaded BeautifulSoup.py from http://www.crummy.com/software/BeautifulSoup/ and being a n00bie, I just placed it in my Windows c:\python25\lib\ file. When I type "import beautifulsoup" from...
0
by: Basha J P M | last post by:
I am beginner in python. I am working through the tutorial examples from http://www.swig.org/ and have run into some problems. I took the following command instructions from the tutorial on...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.