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
I was on freelancer website and I found this work proposal:
Project Description
Hello
We need experience developer in python.
Only bit that person who has a experience in python and Linux.
I want to execute python code in Booting time before execute Operating
System Desktop.
I know that unless I candidate, I won't have any detail about the project, but anyway it seems odd to me.
From my understanding python is interpreted, which means that it needs a virtual environment, and that's what makes it platform independent. Therefore how can a python script (which doesn't convert 1:1 to machine instructions) run before the operative system? Since I know little about what's going on at boot time (I guess some pre-defined instructions laying in the motherboard ROM are executed, then the bootloader loads in the RAM the OS, and the program counter holds the address for the entry point of the OS itself, but I am just supposing) I ask you whether such a thing could be possible.
Linux, being a UNIX type OS, has the concept of runlevels. Each runlevel has a certain number of services stopped or started, giving the user control over the behavior of the machine. As far as I know for Linux, seven runlevels exist, numbered from zero to six. The "Operating System Desktop" becomes available at run level 5. At boot time the system will pass through several other runlevels before getting to 5. At level 3 the system will be have Multi-User Mode with Networking, and this would be a good level to run what ever python script you need. Maybe check into configuring Linux init scripts.
Related
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 2 years ago.
Improve this question
I know this is a hot topic and many people ask this question but I have the feeling I am missing something. What is the proper way to make a python application for end-users? Like, old-school offline .exe and so on. Many users won't touch the terminal/shell and to be honest most software these days is incredibly easy to install. What I know so far:
There are packages out there that can make your software ready for redistribution like
pyinstaller, cx_freeze, py2exe
I wrote my fairly complex software in like 2 weeks and going crazy for days over making pyinstaller work with my external packages. Is this pain normal? Have I made a mistake by relying on an interpreted language? Because compiling this stuff is mean business. In many other languages you just build the stuff within the IDE and there you go, built.
I am not concerned that my code might be decompiled, so what I have tried is to just create a .bat file with commands to execute my script with my virtual environment(!) python. Can I just manage to have the Python venv in place with my scripts without the user having to install it himself?
Or what is the "usual" way to do this? Use Cython? Or pyinstaller? Praying to the lord of code?
FYI: I am using Python 3.6.8, Windows 8 (don't you dare making fun of me :D) and Pycharm 2019.2
However thank you in advance for your time, regards,
Arjaan
There is no correct or established way of how to create an executable file for your Python project. It's opinion-based.
And how you want to distribute your software is entirely up to you. It can be source code, compiled, as a docker image, through Heroku One-Click deployment, debian package, all of the above, ???.
Having choices is nice. Some people need a really simple solution then Heroku or an exe file is nice. Some people are Docker power users, then a multi-arch docker image is nice. Some people want to modify the source code than having the source code is nice. Some people like debian packages and want your project with a systemd service file automatically enabled and started.
You might also not put into the work of getting docker/debian/heroku to work and just tell them a step by step guide on how to get it to run.
Debian and Heroku route might require some periodic maintenance due to the Linux distros updating to newer versions.
There is so much to it and it is an endless discussion where noone is right or wrong.
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
(I use Mac OS X and Python version 3.4.3).
When I double-click on the Python program (.py), I don't want the source code to load/open in Python IDLE, I just want the program to run in Python Shell?
For example when I click the Spotify Icon App, it just runs the program and doesn't bring up its source code! I understand this maybe a very simple question, but I am really stuck! Any help will be great! If this is unclear feel free to ask me questions.
TLDR: You don't.
This isn't normally done; applications that you double click are usually compiled so that the source code isn't there anymore, instead it's been turned into machine-readable instructions for the computer. Since python code is source code, it's simply not designed to be run like an app.
You can compile your python code into an app every time you want to use it, using something like py2app but then the source-code inside isn't easily editable and it may be fiddly to get complex imports working with this, or multiple python versions. I wouldn't get into the habit of this.
Instead, to run a python file, use the Terminal, and type python file_location where file_location is the path to the file. Alternatively you could navigate in the Terminal to the directory containing your python file and then just use python file_name where file_name is the name of your file.
Only compile your python work into an app when it's at its final stage and ready for "release".
For example, what if your app prints something to the command line? Without running it from the command line where would python print that information? Or what if something goes wrong in it and it returns an error; where would that error message go? Also the newer versions of Mac and their "System Integrity Protection" can make life difficult for bundled apps.
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 6 years ago.
Improve this question
So, I know Python, and I've been thinking of getting a Raspberry Pi, as I heard that you can program it with Python. The thing is, I don't have an extra HDMI monitor at hand, but only a Windows 10 laptop (besides, what use would an R-Pi be if you want to use it in a project, when it has to be plugged in to a monitor, mouse etc.?), so I found an alternative called SSH. After watching a few tutorials, I'm positive that I'll be able to set up an R-Pi wirelessly with ease. However, it still hasn't become clear to me, how I would be able to program an R-Pi with Python over SSH.
My initial goal with the R-Pi is to program it with Python, to do things like from saying "hello world", to controlling the GPIO ports, all without external hardware (except that laptop), but I haven't found anything on the internet that suits my needs. Now, my question is, how do I do such, and to what extent will I be able to control my Pi with Python through another computer?
Thank you in advance for the help!
When you connect over ssh to a raspberry pi you are greeted with a terminal.
In that terminal you can use a command line editor like nano or vim to make and edit files. You can also use the command line to execute them.
In this little session I connect to a raspberry pi and then make a python program and execute it.
trirpi#mycomputer:~$ ssh pi#192.168.1.3
pi#192.168.1.3's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Dec 26 17:41:02 2016 from 192.168.1.83
pi#raspberrypi:~ $ ls
projects
pi#raspberrypi:~ $ cd projects/
pi#raspberrypi:~/projects $ vim aprogram.py
pi#raspberrypi:~/projects $ python aprogram.py
You should learn how to use the command line so you can use commands like cd.
You could also setup a vnc server (I think the new raspbian image has one installed by default). That way you can also see gui's and not only a terminal.
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 7 years ago.
Improve this question
I have recently got a new Mac (2015 MBP with 8gb ram) and I am trying to set up a development environment using 5 different stacks at the same time.
I've previously used a LAMP set up very similar to this - many of my old (client) projects are still based on a PHP MVC framework which uses Foundation and Libsass. While I don't want to make new projects in this way as I want to learn more, I still need to be able to maintain these other projects quickly and easily.
I then had some data projects in Python / Django. On my old mac I used a linux VM through Virtual Box for this (I don't yet own parallels etc).
I've also trying to learn to use the MEAN stack using gulp, browserify and playing around with React JS, as well as Meteor (which has it's own server too) and Ruby on Rails - and I want to do more development with these, but without losing the ability to work on my other projects.
My problem is that whenever I previously switched to using MEAN or Rails, I messed up my file watching / auto compiling for LAMP and Python and it took me ages to switch back. I really like how browserify works - e.g. to auto compile sass files / minify, and auto refresh the page, but I've hit problems with keeping my python server and lamp set up doing the same. I'm clearly doing something wrong and I'm keen to set this up properly with a clean install. All the tutorials I can find online refer to setting up individual stack environments, but I can't find much which refers to setting them up together.
I've decided that running a separate VM for each different stack would knock performance too much, and there are some things which I'd want to use on more than one stack like homebrew.
As such, my question is what are the specific advantages of using something like docker to keep things separate vs finding a way using something like homebrew to set up everything together on a single OS?
I'm aware file watching isn't so easy on docker with virtualbox - but I'm not sure whether to push through and find a work around or to use another way.
Thanks so much - I've been stuck on this for ages. I'm sorry if my question isn't very clear - I'm new to using node / meteor and ruby so I'm not sure the best place to start!
In my humble opinion the best solution by far is to use Vagrant. It's also free.
Not only that you can have a different environment for each project, but you can also script all the custom installations and configurations. You, or a colleague of yours, will be able to replicate the environment with a simple command, vagrant up.
A popular guide for setting up Vagrant for RoR development can be found here. However, contrary to that guide, I gave up using Chef in favor of a simple provision script. A guide can be found here.
Make sure to enable NFS though, else VirtualBox (Vagrant sits on top of it) will be quite slow.
While solutions like Cloud9 or Koding are surely useful for when you do not have access to your development machine, I wouldn't use them for day to day work.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I recently made a game that I enjoy playing, and so do my friends. After they download python for themselves, receive the .py files and then start playing. It's a hastle. I was wondering if there was anyway for me to take my game and all in it, put it in some .html that I host online, and have anyone play it whenever they want.
No, it's not possible to play a python game on a web page. Python is interpreted locally, on the user's computer. They have to download the files in order to play.
However, you can use a utility like py2exe to make your game into an executable file, so it can run on its own without the user having to install python. (I'm assuming this is for Windows -- Macs already have Python installed).
update: Per Anderson Green's comment, putting Skulpt on your site will allow visitors to use python scripts in a web page.
Depending on your version of python you could look at packing it into an executable that would be easier to distribute. But unless there's some way of having your website be a persist ant virtual python environment, I don't think web hosting will be the way to go.
For python 2.x I know distutils is one method of packing an executable, but the last I checked, it wasn't compatible with 3.x.