Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Python binary

Posted on 2011-09-14
4
Medium Priority
?
352 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 17

Assisted Solution

by:gelonida
gelonida earned 240 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 240 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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 …
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

916 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