Solved

Python binary

Posted on 2011-09-14
4
349 Views
Last Modified: 2012-05-12
Hi,

I wrote a code that uses a lot of modules that some other server may not have and I don't want to ask the server admin to install modules to write my code.  Is there anyway to take my python code and all its modules and make it into a single executable?

I am using urllib, os, etc... here you can see the code...


# modules used in this function
import re
import sys
import os
import subprocess
import ystockquote

#download the file first
os.popen("curl -L http://www.bolsadesantiago.com/Theme/preciosacciones.aspx > precioacciones.aspx")
ticker = sys.argv[1]
ticker = str(ticker)
region = sys.argv[2]
region = str(region)

# This function takes as an input the name of a stock and goes to the acciones.aspx file to find the price
def ticker2price(ticker, region):
  if region == "chile":
    file = open("precioacciones.aspx")
    stockstxt = file.read()
    pattern = "NEMO="+ticker+".*right\">"
    result = re.search(pattern, stockstxt)
    price = stockstxt[result.end():result.end()+30]
    price = price.split('<')[0]
    price.replace( '.', '' ).replace( ',', '.' )
    price = float( price.replace( '.', '' ).replace( ',', '.' ) )
    return price

  if region == "global":
    return ystockquote.get_price(ticker)


price = ticker2price(ticker, region)
print price

What I want is an executable, without the need of the server admin to install all the stuff I am using and be able to run my code... is there anyway to do that?

Thanks  a lot!
0
Comment
Question by:dfernan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 17

Assisted Solution

by:gelonida
gelonida earned 60 total points
ID: 36539380
You can look at
http://www.pyinstaller.org/
http://cx-freeze.sourceforge.net/

I personally work mostly under windows and use py2exe

I made very short experiments with pyinstaller, but only under windows

I assume you talk about a linux setup.

So I don't have first hand experience.

0
 

Assisted Solution

by:dfernan
dfernan earned 0 total points
ID: 36539388
Thanks, yes I am looking for an executable on a linux server.  Anyone has any ideas?
0
 
LVL 17

Accepted Solution

by:
gelonida earned 60 total points
ID: 36539564
have a look at the two links of my previous post.

These are up to my knowledge the most popular tools for creating executables on Linux
0
 

Author Closing Comment

by:dfernan
ID: 36558849
Ok answer, although providing links is normally a partial answer... I prefer much better code and self-explanations...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question