Python script uses 100% CPU
<p>Hey I was working with python. In my python file I just have 2 lines like : </p>

<pre><code>#!/usr/bin/env
print("hello")
</code></pre>

<p>and I make my .py file executable and run it(./hello.py) on ubuntu server.
With "top" command, i listed all processes.
hello.py uses 100% CPU.
Why it use 100% CPU(Server has 512MB 1 CPU)</p>

<p>Your incorrect shebang line of</p>

<pre><code>#!/usr/bin/env
</code></pre>

<p>causes the system to launch <code>/usr/bin/env</code> to handle the script, as follows:</p>

<pre><code>/usr/bin/env ./hello.py
</code></pre>

<p><code>/usr/bin/env</code> treats the first argument not containing <code>=</code> and not starting with <code>-</code> as a program to run, so it tries to launch <code>./hello.py</code>. Due to the incorrect shebang line, this once again runs</p>

<pre><code>/usr/bin/env ./hello.py
</code></pre>

<p>It's an infinite loop.</p>

python python-3.x