The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python FAQ. How do I make Python scripts executable? Video tutorial: How to Convert any Python File to .EXE
By Guest on 7th November 2022 07:15:58 AM | Syntax: PYTHON | Views: 194



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. How do I make Python scripts executable?
  2. ========================================
  3.  
  4. On Windows, the standard Python installer already associates the .py
  5. extension with a file type (Python.File) and gives that file type an
  6. open command that runs the interpreter ("D:\Program
  7. Files\Python\python.exe "%1" %*").  This is enough to make scripts
  8. executable from the command prompt as 'foo.py'.  If you'd rather be
  9. able to execute the script by simple typing 'foo' with no extension
  10. you need to add .py to the PATHEXT environment variable.
  11.  
  12.  
  13. How do I make an executable from a Python script?
  14. =================================================
  15.  
  16. See How can I create a stand-alone binary from a Python script? for a
  17. list of tools that can be used to make executables.
  18.  
  19. Recommended video tutorial (watch video below):
  20. How to Convert any Python File to .EXE
  21.  
  22.  
  23.  
  24. Is a "*.pyd" file the same as a DLL?
  25. ====================================
  26.  
  27. Yes, .pyd files are dll's, but there are a few differences.  If you
  28. have a DLL named "foo.pyd", then it must have a function
  29. "PyInit_foo()".  You can then write Python "import foo", and Python
  30. will search for foo.pyd (as well as foo.py, foo.pyc) and if it finds
  31. it, will attempt to call "PyInit_foo()" to initialize it.  You do not
  32. link your .exe with foo.lib, as that would cause Windows to require
  33. the DLL to be present.
  34.  
  35. Note that the search path for foo.pyd is PYTHONPATH, not the same as
  36. the path that Windows uses to search for foo.dll.  Also, foo.pyd need
  37. not be present to run your program, whereas if you linked your program
  38. with a dll, the dll is required.  Of course, foo.pyd is required if
  39. you want to say "import foo".  In a DLL, linkage is declared in the
  40. source code with "__declspec(dllexport)". In a .pyd, linkage is
  41. defined in a list of available functions.
  42.  
  43.  
  44. Why does Python sometimes take so long to start?
  45. ================================================
  46.  
  47. Usually Python starts very quickly on Windows, but occasionally there
  48. are bug reports that Python suddenly begins to take a long time to
  49. start up.  This is made even more puzzling because Python will work
  50. fine on other Windows systems which appear to be configured
  51. identically.
  52.  
  53. The problem may be caused by a misconfiguration of virus checking
  54. software on the problem machine.  Some virus scanners have been known
  55. to introduce startup overhead of two orders of magnitude when the
  56. scanner is configured to monitor all reads from the filesystem.  Try
  57. checking the configuration of virus scanning software on your systems
  58. to ensure that they are indeed configured identically. McAfee, when
  59. configured to scan all file system read activity, is a particular
  60. offender.
















Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.

Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.

See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license
  • Recent Pastes