Run python script at windows startup [duplicate] - python

This question already has answers here:
How to start a python file while Windows starts?
(11 answers)
Closed 2 years ago.
Requirement :- I want my python file to run at windows startup
I am using Anaconda, spyder as IDE. My python file is using a package which running absolutely file when I run on Spyder itself.
Now when I have created a bat file and i have given python exe file and python script along with path
When I run it gives me error that package has not been installed.
so same file running in spyder but when trying to run .bat file it giving me error.
Please guide me how should I achieve this task.
Thank you.

You can place a shortcut that runs
C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\python3.exe myfile.py
You can find where your install of python is at with where python3 in a command prompt.
Place the shortcut in shell:startup and will run after all startup programs have run.
But since you using your ide's python instance you have to run the python environment source from its, sadly I don't use Spyder IDE and most IDE are closed python environments and are setup within their own terminals.

Related

Environmental variables set but still cannot execute from command prompt after install Python and PyCharm [duplicate]

This question already has answers here:
Where is Python's sys.path initialized from?
(2 answers)
Closed 1 year ago.
Beginner here. Installed Python 3.9 and PyCharm. Trying to execute from command prompt in Windows 10 Pro. I checked the environmental variables with the route to the folder where the executables are but still does not work.
Use :
Python3 Helloword.py
Or:
Python Helloword.py
You have to tell to OS this is a python file. You just wrote file name but didn't tell what's execute this.

Python script multiexecution [duplicate]

This question already has answers here:
Create a single executable from a Python project [closed]
(3 answers)
Closed 1 year ago.
I want to execute three python script that I have developed. I found one doubt, how could I do it using a python script?
I want to convert it into a .exe, because our solution is thought to be executed in machines without python installed so having an unique script would be helpful.
Edit: I don't know the cause of the closure, I know how to use pyinstaller, my question was how can I execute 3 python using a python script or if it is possible.
Any suggestion? Thanks!
To package script and all dependencies you can use Pyinstaller, see here.
To execute multiple script (or exe) you can write a bat file that start the 3 exe or use them as services, based on your needs.
Use pyinstaller it can convert python to executables. You can get it up and running simply by doing
pip install pyinstaller
pyinstaller myfile.py

Running a Python script on CMD opens Visual Studio [duplicate]

This question already has an answer here:
Need ot use a batch file or Power Shell to set a file extension to a program [closed]
(1 answer)
Closed 5 years ago.
When I try to run a Python script, instead of running it, Visual Studio pops open with the script. I initially thought that the CMD is not hitting the right interpreter. I checked the PATH and it was set correctly. I am using Python 3.6 installed with Anaconda on a Windows system.
Has anyone else experienced this before?

How to my "exe" from PyCharm project [duplicate]

This question already has answers here:
Create a single executable from a Python project [closed]
(3 answers)
Closed 8 years ago.
Writing some project on Python via PyCharm.
I want to get an exe file from it.
I've tried to "Save as->XXX.exe" - but ,when i'm trying to execute it there is an error "file is not supported with such kind of OS"
p.s.
i've got win7 x64,it doesn't work on x32 too.
You cannot directly save a Python file as an exe and expect it to work -- the computer cannot automatically understand whatever code you happened to type in a text file. Instead, you need to use another program to transform your Python code into an exe.
I recommend using a program like Pyinstaller. It essentially takes the Python interpreter and bundles it with your script to turn it into a standalone exe that can be run on arbitrary computers that don't have Python installed (typically Windows computers, since Linux tends to come pre-installed with Python).
To install it, you can either download it from the linked website or use the command:
pip install pyinstaller
...from the command line. Then, for the most part, you simply navigate to the folder containing your source code via the command line and run:
pyinstaller myscript.py
You can find more information about how to use Pyinstaller and customize the build process via the documentation.
You don't necessarily have to use Pyinstaller, though. Here's a comparison of different programs that can be used to turn your Python code into an executable.

How to make python scripts executable on Windows? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Set up Python on Windows to not type python in cmd
When I use python on Linux, or even Mac OS from command line, I take advantage of the shebang and run some of my scripts directly, like so: ./myScript.py. I do need to give this script executable permissions, but that is all.
Now, I just installed Python 3.1.2 on Windows 7, and I want to be able to do the same from command line. What additional steps do I need to follow?
This sums it up better than I can say it:
http://docs.python.org/faq/windows.html
More specifically, check out the 2nd section titled "How do I make Python scripts executable?"
On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to make scripts executable from the command prompt as foo.py. If you’d rather be able to execute the script by simple typing foo with no extension you need to add .py to the PATHEXT environment variable.

Categories

Resources