Solved

Python binary

Posted on 2011-09-14
4
346 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
  • 2
  • 2
4 Comments
 
LVL 16

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 16

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

810 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