Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
py2exe is great, and I use it whenever I want to package up a python program to run on a Windows system.
My question is, is there an equivalent tool that I can use to package up the program on Windows, but that I can then run on Linux?
here is also PyInstaller that supports Linux, MacOS and Windows - I have not used it (yet) so I don't know if you can package stuff on windows for linux, but glancing over the manual it seems to be possible.
EDIT:
The FAQ states explicitly that you can not create a windows package from linux and no mac os package from linux neither - there is nothing about creating a linux package from the other two sources, but it might not work.
EDIT2:
After googling a bit I found cx_freeze which might also be worth a look.
I really doubt that you can do something like that at all.
What you could do is just configure yourself 3 build VMs one for Windows, one for MacOS and one for Linux that have everyhing you need to run your program.
Then use either a combination of py2exe/py2app/pyinstaller to generate a distribution for each of the platforms. You will have 3 different pacakges but each one of them will be nicely packed and with no need to install anything else on the client machines.
Ok, I've done this. It's a little hacky, but it works very well for my use case.
The gist of it is to use ModuleFinder to find all imported modules, filter out any system ones, compile them and zip them up.
Unfortunately my code for this is littered with additional complications that don't have any relevance to this question, so I can't paste a working program, just some snippets:
zipfile = ZipFile(os.path.join(dest_dir, zip_name), 'w', ZIP_DEFLATED)
sys.path.insert(0, '.')
finder = ModuleFinder()
finder.run_script(source_name)
for name, mod in finder.modules.iteritems():
filename = mod.__file__
if filename is None:
continue
if "python" in filename.lower():
continue
subprocess.call('"%s" -OO -m py_compile "%s"' % (python_exe, filename))
zipfile.write(filename, dest_path)
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Please forgive my ignorance. I'm using Mint 18.1. I installed Python 3.6 from its source code but it failed.
if I enter python, version 2.7 runs.
if I enter python3, version 3.5 runs (both were preinstalled with my Mint)
if I enter python3.6, i get a 'command not found' error.
Then I found and followed Error Installing Python.
My question is how to do i set it up so python3.6 runs without having to enter $HOME/py36/bin/python in the terminal.
Thanks
edit
NEVERMIND. got it. thanks a lot, guys.
You could add an alias in your shell's config file (.bash_profile or similar, if you're using bash) that points python3 to $HOME/py36/bin/python.
To do this, you need to find your shell configuration file (~/.bash_profile, ~/.bash_login, or ~/.profile) and edit it so that it contains an alias. Aliases take the form of newcommandname='oldcommandname -flags', so you want something like python3="$HOME/py36/bin/python". Note how there are no spaces around the equals sign, and double quotes, as that is required for this to work.
Alternately, you could add $HOME/py36/bin/ to your $PATH variable, so that your shell automatically looks there for binaries. You can do this by editing your shell configuration file like above to say PATH="$HOME/py36/bin/:$PATH". This makes your shell look here for executables before anything else; PATH="$PATH:$HOME/py36/bin/" will cause your shell to look for executables here after looking everywhere else. I don't recommend this, tbh; do the first one.
The best way to maintain several different versions of python is via conda, which allows you to create a variety of environments with different Python versions and packages. Conda is part of the Anaconda scientific Python distribution.
Anaconda
There are lots of tutorials on YouTube and the web.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I've been writing and using short Python scripts (~100 lines) for various tasks in Ubuntu using the Geany text editor, which I like for it's simplicity (setup, F5 to run, etc.) and syntax highlighting.
I would like to know if there is a similar application for Windows. Because what I've found so far requires downloading 3 different applications or using a big IDE like eclipse.
You can use the Geany build for Windows
You can still use Geany to run Python in windows.
But if you need to debug, auto-complete and beautiful IDE, I suggest that you head for pycharm.
Microsoft's Python Tools for Windows now works as a plugin for Visual Studio Express (and not just the paid version of Visual Studio) so you get nice free solution that has everything you need with a pretty simple install. It can be found at: http://pytools.codeplex.com/
Any good programmer's text editor will do. I personally use SublimeText 3, but I've used Eclipse + PyDev before to great success, and the usual suspects (emacs, vim, Notepad++) will work just fine too.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
How do I convert my Python app to a .exe? I made a program with tkinter and was wondering how to make it possible for others to use. I use Python 3.3. I searched for a bit but could not find anything.
cx_Freeze does this but creates a folder with lots of dependencies. py2exe now does this and, with the --bundle-files 0 option, creates just one EXE, which is probably the best solution to your question.
UPDATE: After encountering third-party modules that py2exe had trouble "finding", I've moved to pyinstaller as kotlet schabowy suggests below. Both have ample documentation and include .exes you can run with command line parameters, but I have yet to compile a script that pyinstaller isn't able to handle without debugging or head-scratching.
Here's a simple convenience function I use to build an .exe with my defaults from the interpreter (of course a batch or similar would be fine too):
import subprocess,os
def exe(pyfile,dest="",creator=r"C:\Python34\Scripts\pyinstaller.exe",ico=r"C:\my icons\favicon.ico",noconsole=False):
insert=""
if dest: insert+='--distpath ""'.format(dest)
else: insert+='--distpath "" '.format(os.path.split(pyfile)[0])
if ico: insert+=' --icon="{}" '.format(ico)
if noconsole: insert+=' --noconsole '
runstring='"{creator}" "{pyfile}" {insert} -F'.format(**locals())
subprocess.check_output(runstring)
I have found PyInstaller to work the best.
You have many options for example you can pack everything to a one file exe.
I love to use it together with Cython for speed.
You can use cx_Freeze. There is a guide here.
Use Pyinstaller.
After installing it, open terminal in the directory where your project resides.
$ pyinstaller script1.py script2.py ... (where script1, script2, etc. are all the scripts used in your project.)
After command is completed, open dist folder and enter the subdirectory. There you'll find an executable.
Hope it helps.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm a designer who writes mostly Sass, Less (CSS pre-processors), HTML, Javascript and usually starts off with static site generators such as Jekyll, Yeoman, etc. While working with developers who code in Python, Ruby, Clojure, I help with the templates. In my free time, I design wordpress themes and write plugins in PHP. I run grunt regularly and bower helps me with components that I need for my designs.
This means my system is littered with Ruby Gems, Python libraries, Node Modules. They are either installed via gem installations, pip, brew or npm. Now you realize that my system is a mess even though it works. I really want to do stuffs in a sane manner, the right way.
So, what are the best practices for installation and management of all the libraries, core tools, etc. for a developer on Mac OS X. Point me to resources that I can read, ponder and practice.
Here is the scenario. You're a seasoned developer and I'm your friend who just got a new Mac OS X system. I'm a designer who will work with Python (mostly with Django), Ruby (with Rails), Clojure, PHP, Sass, Less, Compass, CoffeeScript, Git, NodeJS, Grunt, Bower, Jekyll, Yeoman and alike. As a friend, you know that I'm not a 'programmer' but a developer-friendly 'designer'. How can you help me setup my Mac? And I don't want to come back again when I get a new Mac in future, I should be able to just transition smoothly from my old setup.
Thanking in anticipation.
Github open sourced there developer environment setup tools. You could try that out. http://boxen.github.com/
For python I recommend using virtualenv to setup libraries instead of installing them globally. https://pypi.python.org/pypi/virtualenv
I am not sure what you meant by "How can you help me setup my Mac?". It seems that you are very much comfortable installing all the dependencies(gems and all) for your projects. If you want to automate all these environment installation setup then you may go ahead and write a generic shell script to install ruby, python and other stuff and reuse when you have a new machine :) and it has nothing to do with Mac OSX or any other OS. You just need to put correct package/version to fetch and install/compile accordingly in the script.
Would be great if you can put a specific question here in case you are facing technical problem installing any of the above packages.
If all that you are worried about is quickly setting up a new machine, use a backup software to setup the new machine. You can also try to use a custom time machine setup with just the folders that you are interested it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have very simple task to accomplish in python. Need to draw textual data (Unicode) as rows on the screen, navigatable and user can select/deselect row. However, this should work on headless Linux, as well as Windows or Mac OS. Curses doesn't have Windows port. Console module from Fredrik Lundh works only on Windows. I could use both libraries and check OS, but then it takes double effort to make/maintain the same functionality on 2 different libraries.
I'm looking for simple multiplatform console library to draw what I've described.
At a lower level you will have to use curses and there are several choices for the underlying curses library on Windows which may or may not work. You won't have any real problems with curses on UNIX so if I were you, I would get it working on Windows first and if a particular feature doesn't work their, program around it. The UNIX port should be painless.
PDCurses for Windows is available as a DLL or source code and it is possible to interface directly to any DLL using the ctypes module. There is a tool which can automatically generate a ctypes wrapper for you called ctypesgen.py http://wavetossed.blogspot.com/2011/07/asynchronous-gnu-readline.html I'm not sure if that works for a Windows DLL quite so automatically, but it does work from header files so it is worth a try.
For more background on ctypes, have a look at some of the questions here like Scheduling function calls in a Python curses UI
I recently had a similar issue for a package I was putting together (https://github.com/peterbrittain/asciimatics). I wasn't very happy with the solutions that required you to install (or worse) build separate binary executables like PDCurses or cygwin, so I created a unified API that provides console colours, cursor positioning and keyboard input for Windows and UNIX platforms.
There is a gallery of sample applications here. In more recent releases, I have also added a set of widget objects to allow you to create TUIs like this:
This is now live and has been tested on CentOS 6/7 and Windows 7/8. You can install it from PYPI using pip and then use the Screen class to do exactly what you want. If not, please post an enhancement request on GitHub and I'll see what I can do.
I use urwid. It's documentation is poor, but on the other hand, its source base is very compact. It supports Unicode well and works fine on Cygwin. Doesn't seem work in native CMD.exe, but it's worth closer investigating seeing how the curses dependency is only optional.
Examples from the project site:
(source: urwid.org)