Solved

Python binary

Posted on 2011-09-14
4
347 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 …
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…

861 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