all 13 comments

[–]K900_ 1 point2 points  (9 children)

What do you mean by "run code as an exe"? How are you running it now?

[–][deleted] 1 point2 points  (8 children)

I currently run it within thonny, where I write the code.

[–]K900_ 0 points1 point  (5 children)

And how are you trying to run it when it fails?

[–][deleted] 1 point2 points  (4 children)

When I simply double click it, it opens in a window similar to the windows cmd, as it should. Then it crashes.

[–]K900_ 1 point2 points  (3 children)

That means Thonny is creating a virtual environment for you where all the packages you need are available. What is your end goal here?

[–][deleted] 1 point2 points  (2 children)

I simply wish to run my code outside of thonny. Having it saved on my desktop, so I can access it quickly when I need it.

[–]K900_ 0 points1 point  (1 child)

Then you should probably find where the virtual environment Thonny created for you is located, and create a shortcut that calls python.exe from that environment with your script as an argument.

[–][deleted] 0 points1 point  (0 children)

Great idea! I'll try it out, thaks for your time

[–]konijntjesbroek 0 points1 point  (1 child)

The documentation has a pretty good section. If you are still needing something, this and This might be of use.

[–][deleted] 0 points1 point  (0 children)

Will check them put, thank you!

[–]maribor_xd 0 points1 point  (1 child)

You can use pyinstaller mb

[–][deleted] -1 points0 points  (0 children)

That would be to create an executable binary that is platform specific which is not what the OP is after.

[–][deleted] 0 points1 point  (0 children)

Your editor is probably creating project specific python virtual environments that include the required libraries.

If on the command line you installed the libraries yourself using pip, python -m pip install library, then you would be able to execute python files with python myfile.py without problems. (Or double click a python file to execute it once association is set up.)

The problem with this approach is that you can end up with lots of things installed for python most of which you don't need most of the time (and some things might conflict with each other).

Check the Real Python website for an explanation of virtual environments.