Solved

Python binary

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now