Firstly, please ask programming questions on Stackoverflow unless they are specific to Unix/Linux shell programming.
Python doesn’t execute main
(or any other) function by default.
You can either just do:
#!/usr/bin/env python3 import sys sys.stdout.write("Hello")
or if you want to keep the function, but call it when the script is run:
#!/usr/bin/env python3 import sys def main(): sys.stdout.write("Hello") if __name__ == '__main__': main()
The second method should be used if you are going to import the script into some other file, but otherwise, use the first one.
Also, you can just use the Python print
function, which writes to stdout by default.
#!/usr/bin/env python3 print("Hello")
Related Posts:
- ping: google.com: Temporary failure in name resolution [closed]
- Docker System has not been booted with systemd as init system
- CentOS vs. Ubuntu [closed]
- How to install python3 version of package via pip on Ubuntu?
- Docker error : no space left on device
- How to establish ssh key pair when “Host key verification failed”
- localhost/phpinfo.php
- After installing with pip, “jupyter: command not found”
- gpg: no valid OpenPGP data found
- gpg: no valid OpenPGP data found
- E: Unable to locate package mongodb-org
- How to open the terminal in Atom?
- Valgrind permission denied on file
- nginx – nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
- ImportError: No module named ‘xlrd’
- How to install Boost on Ubuntu
- How to verify if nginx is running or not?
- pdflatex not found. pdflatex is needed for pdf output
- Nginx: stat() failed (13: permission denied)
- PIP Could not find any downloads that satisfy the requirement SQLAlchemy
- MySQL: How to reset or change the MySQL root password?
- Removing all installed OpenCV libs
- Vim: No write since last change, even though I changed the file
- How to kill a process on a port on ubuntu
- whats the meaning of curl “-s” and “-m”
- How do I ask apt-get to skip any interactive post-install configuration steps?
- How to view all ssl certificates in a bundle?
- How to remove the “installed manually” flag and revert to “automatically installed” with apt-get?
- How do I get apt-get to ignore some dependencies?
- How do I auto-start docker containers at system boot?
- How do I reattach to Ubuntu Server’s ‘do-release-upgrade’ process?
- How to determine JAVA_HOME on Debian/Ubuntu?
- How to start/stop iptables on Ubuntu?
- Which ports do I need to open in the firewall to use NFS?
- list all packages from a repository in ubuntu / debian
- dpkg-reconfigure: unable to re-open stdin: No file or directory
- How can I edit the welcome message when ssh start?
- How does Ubuntu keep track of the “System restart required” flag in motd?
- Amazon Linux vs. Ubuntu for Amazon EC2 [closed]
- Automate the installation of postfix on Ubuntu
- Best location to keep SSL certificates and private keys on Ubuntu servers?
- Why is ssh agent forwarding not working?
- Relative imports – ModuleNotFoundError: No module named x
- How do I upgrade the Python installation in Windows 10?
- Python Variable Declaration
- Best way to convert string to bytes in Python 3?
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- Relative imports in Python 3
- How to print like printf in Python3?
- What are type hints in Python 3.5?
- TypeError: ‘type’ object is not subscriptable when indexing in to a dictionary
- Invalid character in identifier
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to find all the indexes of a recurring item in a list?
- Unable to initialize device PRN in Python
- How do you use subprocess.check_output() in Python?
- (Help) TypeError: ‘str’ object cannot be interpreted as an integer
- builtins.TypeError: must be str, not bytes
- Python error message io.UnsupportedOperation: not readable
- takes 1 positional argument but 2 were given
- Python 3 ImportError: No module named ‘ConfigParser’
- re.search().TypeError: cannot use a string pattern on a bytes-like object
- Add Legend to Seaborn point plot
- How can I install Python’s pip3 on my Mac?
- How does “cat << EOF" work in bash?
- How do I compare two string variables in an ‘if’ statement in Bash?
- Get ZeroDivisionError: float division in python
- Why Am I Getting ELIF Invalid Syntax Error?
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- “for line in…” results in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte
- TypeError: cannot unpack non-iterable NoneType object
- Shebang doesn’t work with python3
- Choosing a Windows automation scripting language. AutoIt vs Autohotkey
- Unable to locate package libapache2-mod-php7
- pythonw.exe or python.exe?
- Directing print output to a .txt file
- How to read the last line of a file in Python?
- How to count lines in a document?
- What does `set -x` do?
- Converting a sentence to piglatin in Python
- How to fix ModuleNotFoundError: No module named ‘pip._internal’ with python source code installation
- Python Error – TypeError: input expected at most 1 arguments, got 3 [duplicate]
- A general tree implementation?
- No module named ‘openpyxl’ – Python 3.4 – Ubuntu
- Print empty line?
- Checking to see if a string is an integer or float
- How to know/change current directory in Python shell?
- wget: unable to resolve host address `http’
- How to use cmp() in Python 3?
- Error: No module named ‘fcntl’
- Python can’t find file
- Error handling in Bash
- how to search for a directory from the terminal in ubuntu
- Pip install on Mac OS gets error: command ‘/usr/bin/clang’ failed with exit code 1
- TypeError: ‘zip’ object is not subscriptable
- Can I hide all server / os info?
- How to fix PuTTY showing garbled characters? [closed]
- What does passing the -xe parameters to /bin/bash do