Shipping Interpreter with Python application - python

I am new to Python. Please excuse me if my question seems stupid. I have spent a lot of time before posting this.
When I searched for shipping python interpreter with the applications, I found solutions including installing separate applications, using third party modules, etc...
I was thinking of more direct approach: I first install python interpreter on my machine (windows). Then I ship the installed python interpreter (copy and paste the folder) with the pyc file of my application. And finally I create a simple batch program that executes the interpreter and running the pyc file. In this case, the user can simply run the application by simply running the batch program. I have tried it and it worked.
Although this solution seems the most obvious and the easiest one, I am in a doubt about it because I cannot find any one mentioning it. Is there anything wrong with my solution? I usually create desktop applications for windows.
Thanks in advance.

Make a virtual environment for you application and then run run the command python filename.py --onefile --windowed while still being in the virtual env. activated,

Related

Making a python standalone Linux executable on windows

I have a python server application that I wish to put onto my server. I have tried to run the python scripts on my server, I moved the file with sftp and I installed the dependancies with pip. No luck, it doesn't use my modules even after I install them. It says the module I installed isn't a thing, when when I run pip again it says it is already there. I read about standalone executables a little, but I only found documentation on windows ones. I know Linux cannot run exe files, but is there something similar.
Another thing might be my unfamiliarity with pip. I use the terminal in py charm which automatically puts my pip modules into files. When I do that on my ubuntu machines there is no file created in my directory. (Feels like a problem to me)
So I don't want to leave this open in case anyone else see this and needs help. I had forgotten to install my modules, so I did that, and then to run my two programs I just use screen now to host different terminals for each program. It isn't very hard.

Python: Installing virtual environment on network drive

I wrote a Python program that I use daily at work, and I was hoping to be able to pass it along to others who have zero programming experience.
I need to avoid having each user download Python and the relevant dependencies, and I also can't compile it into an executable.
I tried creating a virtualenv on a network drive, and made a .bat file that activates it and runs the script in the environment. It works for me, but other users get a "Can't find python34.dll" error when they try to run it.
Is there anyway around this? Am I going about this incorrectly? The goal is to have non-Python users be able to run the script without installing Python or compiling it all into a .exe.

Install and execute python3 inside one same independent folder

I have a small program written with Python3 that I'd like to install on friends computers. The main issue is that not every computer has a Python3 installed on it (mostly Python2-). Do I have to install it on each computer I want my program to run?
I thought it would be possible to install Python3 inside a separate directory, as shown below.
Then, I would be able to use a shebang to run the right version of Python installed inside myProgram folder.
#!C:\myProgram\python3 python
# Test
a = input('Entrer un nom:')
print(a)
When I double-click on myProgram.py file, a window opens and closes immediatly...
Is this a bad idea or not? Is there a way to achieve that differetnly if so?
You could create an executable from the python script rather than installing all of python 3 on their machine. There's a few ways you can do it, see this answer.
I'd have a look at pyinstaller.
Add Python 3 to your friends machine to execute your program.
What'is the utility to run such a small program on their computers?
The way you propose won't work.
Windows does not know about shebangs.
Even if it did, this one would only work if a user installed the program to C:\myProgram (which is not a really appropriate place, and the user might not have the rights to install it there).
There are ways to make a python program portable w/o having the need to have a Python runtime installed. Alas, I currently don't know their name.
Or, if that is feasible, install Python 3 on their machines, but I don't know if that might break any programs wanting to use Python 2.
There're different tools which can pack you program to single .exe file or make an installer. Here's my solution from 2016 year - Python - create an EXE that runs code as written, not as it was when compiled
Now it will be little easier :)

Python: "No virtualenv active"

I installed PyCharm 2.7 under Windows 8.1. It works fine, but every time I run a program, I get the following warning:
WARNING:root:No virtualenv active
Why does it happen and how can I fix it?
Program you run needs a virtual environment to run. This is a nice python feature that allows you to isolate a python program within the scope of the specific python set of libraries it may need. If you do not run more than one Python program you may not be really worried about it. However, it you do, I would recommend to ready about virtualenv first.
ps. Also, it might be just a debug log for developers to make sure they switched virtual env.

Is there any way to make a Python program that has the user use the terminal (NO GUI) into a stand-alone for Mac?

I finally got py2app to work, and my program was made. However, it won't open because it relies on the terminal and raw_input. I just found out py2app is more for GUI interfaces.
All I want, is to turn the program into an application my users can click on, and it'll open in Terminal. Without them having to either install Python, or go to the terminal and type python "filename" (also, don't they have to set up the paths and everything to do that?).
Please help; I've been pulling my hair out all day looking for the answer. If this isn't possible, I'm just going to give them the .py file and instruct them to start it with python in the terminal and hope it's already set up so they can do that.
I know that on a mac you change the extension of the file to .command and that will make it so you can just click on it and it will run through the terminal if that's what it is specified to do. However I'm not sure if it will work if they do not actually have python installed.
Using PyInstaller http://www.pyinstaller.org/ it's possible to make an executable for different platforms. I believe OSX is supported.

Categories

Resources