Installing and using python on a client computer - python

I am writing a small python installer application that will run on linux. However, i don't know which Linux in advanced, so i cant write for any specific python version since i have no idea what is installed on the client computer, if any (do i? is there any thumb rule for python version preinstalled on a Linux machine?).
Is there a optimal way to install a local python version on a client's computer in some temporary directory, use it for the application run-time, than remove it when it is done?

Do you know the machines architecture? If so simply download the python version you want to install on the linux architecture on your server/box/your computer then compress it and upload it to a server somewhere. (or use the link on python.org)
then simply make a bash script to download it and uncompress it. Then install it using shell commands like make or cmake ./configure within the install directory
If you dont know the architecture or are trying to use it on some generic or other you could cross compile it using these cross compilers to cross compile python (or anything coded in c(/c++?))
http://pastebin.com/mxWqBvy8
Typically the general 'rule of thumb' for the python version would be python2.7.x
You could use Pyinstaller to "compile" your python (its origanally win) there is a linux version somewhere, fairly sure its as easy as pyinstaller test.py)
Removing it shouldnt be that hard, rm is universal everywhere

You can bundle your programs with Python itself without requiring the target machine installed Python Interpreter on it.
Check this out: https://wiki.python.org/moin/Freeze

Related

Changing Python path variable in Openshift NodeJS cartridge

I have a NodeJS web server (Express) locally that uses Python-Shell to fire off Python scripts (mostly scraper stuff using PyCurl). The Python scripts also use various modules that I have installed using pip. This all works locally with no issues, running Node v4.1.1 and Python 2.7.10.
Now, I need a server to run this setup on, and I'm cheap, so I really want to use Openshift, which I have used before for other Node-only projects.
My problem is that I need to work with Python, and while it is installed (v2.6 anyway), I can't do much with it. Pip is not installed at all, and I don't have administrative rights to install it. Easy_install seems to be present, but I get permission issues when trying to execute it (even just the test via "easy_install" with no parameters). I need pip to install several modules for my Python scripts.
I was able to follow the instructions here and get Python 2.7, setuptools, and pip all installed successfully, but they are only available by prefixing the path $OPENSHIFT_DATA_DIR/bin (which resolves to /var/lib/openshift/[my-id]/app-root/data/bin). So...
\> $OPENSHIFT_DATA_DIR/bin/python -V
Python 2.7.3
I can also successfully run my Python scripts if I prefix the python command with that path.
So my question is how can I either get python-shell to use that path for Python, or how can I update Openshift's environment variables so that the standard "python" command is pointed to my manually-built v2.7.3 executable?
I'm stumped, but I know next to nothing about Linux or Openshift's architecture specifically, so I'm hoping you guru's out there can help me out!
If someone ever has a real answer to this, feel free to post it up, but I ended up just abandoning Python altogether and re-wrote the scraper in Node using Cheerio. Much better!

Create standalone applications with py2app by not using the system installation of Python on Mac?

I am using py2app to package a Python application to be used on other Mac computers. I am currently running OSX 10.7.5 and the system Python installation on my computer is Python 2.7.1. When I package the program with py2app, it works on my computer, but will not work on another computer - the error that comes up is it cannot locate a Python runtime.
From what I have read about this, it looks like my py2app build is using the system installation of Python on my computer and therefore will only create a semi-standalone application instead of a standalone application.
Also, I have seen that to fix this you need to package it with a separately downloaded Python. I have downloaded a separate Python and even tried to change my PYTHONPATH in my .bash_profile file, but cannot seem to get py2app to build with a different version of Python.
Can anyone point me in the right direction as to how to do this?
I have read other questions and wasn't able to find out how to do it in my case. If there is any other information you need to know to help, please let me know.
py2app builds the application bundle using the running version of python. To use the separate install of python you therefore have to make sure that py2app and the other libraries you use are available in that installation of Python, then use that installation to build the application.
For example:
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install py2app
$ .../bin/easy_install ...
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py py2app
The simplest way of handling this IMO is by utilizing MacPorts. You can download and install a standalone version of Python and just about any other package you might need.
Get macports: https://www.macports.org
sudo port install py27-py2app
sudo port select python python27
Now your standalone Python is the default, and py2app will run and bundle using that version of Python.

How to install a multipart python program on Mac?

Finally making a legitimate mac installer for my product. I've made a successful Windows installer with Inno installer. I'm not sure how to do this in Mac.
This must happen:
-Python is installed
-Wx is Installed
-Py Serial is installed
-Program is copied
-Shortcut is made.
I was doing this with Bash scripts before, but my customers having been complaining about those. Perhaps X-code package maker is the solution? I know the recommended method is "just copy files" but these libraries must be installed somehow.
Thanks in advance!
Unless I am using Fink for installing packages, I usually just download the .tar.gz file from the source and install it from terminal inside the unzipped folder containing the install.py file. Terminal command:
sudo python ./setup.py install
If you would like, I can show you how to set up and use Fink, which is another easy way to install packages / libraries.
tl;dr: py2app will make a self-contained application bundle out of your Python scripts, making it real easy to employ the 'just copy files' installation process. The libraries you need are bundled into the app bundle itself, so they don't need to be installed systemwide.
Also check out Optimizing for Mac OS X from the wxPython wiki; it gives good tips on using py2app and other useful information on building a Mac-friendly Python application.
On OS X, programs are generally installed through one of three ways: the Mac App Store, a package installer (.pkg/.mpkg), or a copyable application bundle on a disk image (.app in a .dmg). Each has its strengths and weaknesses.
The Mac App Store requires that you subscribe to Apple's restrictions and requirements, and may be a good choice for apps expecting wider distribution (though, nowadays, it can be a good way to reach that wider audience easily). Copyable application bundles are by far the simplest installation method pre-App Store, and still remain one of the more popular ways to install programs. Finally, an Installer package is a user-friendly way to install more complex programs requiring more than a simple application bundle (e.g. system services, files in particular directories, system-dependent components, advanced installation logic, etc.). I should note, though, that do exist complex applications which ship as application bundles and perform the bulk of their 'installation' at first run.
My experience with the Mac App Store is limited, so I won't talk about it. You can find more details at the official website.
Python is quite amenable to being shipped as an application bundle. You can use py2app to automatically create an application bundle for the program, and then drop that bundle into a Mac disk image (.dmg) using Disk Utility to create a complete installation package. This doesn't support making shortcuts, but on OS X it is much more usual for users to just drop the app into /Applications and make the necessary dock shortcut themselves if they want.
The next way is to make a metapackage (.mpkg) which will be installed using the OS X standard Installer utility. This is in line with what users will expect from a Mac application. IIRC, both Mac Python and wxPython ship as .pkg already, which should make it easier to integrate them into a metapackage. bdist_mpkg can help with making packages for pyserial and your own program, which can be added to the metapackage. Finally, using the third-party dockutil script, you can automatically add a dock shortcut. Note, however, that installers generally do not add shortcuts to the dock; it is more usual to have a program installed to the /Applications directory.`

Opencv 2.2 not recognized on Python 2.7 (Ubuntu/Windows XP)

I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.

Python on AIX: What are my options?

I need to make some Python applications for a work project. The target platform is AIX 5.3.
My question is: What version of Python should I be using?
My requirements are:
The Python version must be easy to install on the target machines. Others will do that according to instructions that I write, so no compiling from source or anything like that.
The Python version must have ncurses or curses support (I'm making a form handler).
I've found two different precompiled versions of Python for AIX, but one (2.1.something) didn't include the curses module, and the other (2.3.4, RPM format) had prerequisites that I failed to fulfill).
Any help would be greatly appreciated.
Use the AS Package of Python 2.6.3.7 from Activestate. They have a binary package for AIX on their download site.
If you don't have an AIX machine to test it on, the install works the same way on Solaris or Linux, so you could write your documentation based on that. Basically, you ungzip the tarball file, use tar to unpack the archive, change directory to the unpacked folder, run a shell script to install it, tell the shell script what directory to place it in, and wait.
Normally this would be used to install into a user directory, without superuser permissions, but you could install it anywhere that you like. You might also need to edit the system profile in order to make sure that all users can find the Python binary.
I suggest the latest Python 2.6, because it has a lot of bugfixes, and there is now a critical mass of 3rd party libraries ported to it. Also, the standard library includes a lot of useful stuff that you used to have to collect separately. Curses is in the standard library of Python 2.6.
Make sure to avoid Python 3.1 since it has not yet matured enough and provides few benefits for most business applications development.
I'd compile it from source myself and tell them where to download it from in the instructions
We've used ActiveState's Python as well as Pware's compiled version. Both have worked well. For AS, we've used 2.5 and 2.6. For Pware, just 2.6. Both 2.5 and 2.6 from AS support curses on our machine.
I've compiled from source but usually wind up having trouble with with ctypes or SSL. Currently I have the Frankenstein option going of AS Python2.6 installed but I pulled out a couple of *.so files from Pware's. I'm using GCC since we've never ponied up for a compiler but depending on what you need from Python, it's definitely doable if I can do it.
I will mention that AS Python claims to be 100% compatible with standard Python and it has been for everything we've done so far (mostly web applications).

Categories