I cannot run my python script in powershell?
<p>Okay so before I asked this question, I searched for answers through other
 questions. For starters, I am learning python through Learnpythonthehardway.org
now I am learning a lot and already on the fourth example but I need to solve this as its really bothering me.
So when I go to run the file, I type:</p>

<pre><code>ex3.py 
</code></pre>

<p>and I get this:</p>

<pre><code>ex3.py : The term 'ex3.py' is not recognized as the name of a cmdlet,         function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the  path  is correct and try again.
At line:1 char:1
+ ex3.py 
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (ex3.py:String) [],    CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
</code></pre>

<p>So then I check my path and its </p>

<pre><code>C:\User\Ally&gt; 
</code></pre>

<p>so I save the file under Ally AND it still doesn't work. I am so done and cannot find a solution. since I need my files to run, I found a temporary method and this is how I run my files,</p>

<pre><code> C:\Python27\EX\ex2.py
</code></pre>

<p>Powershell can run python by itself and my CMD as well. I change both PATH and PATHTEXT to run Python and .py files.</p>

<p>I do not want to use my temporary fix, I want to find a permanent solution, (A problem should NOT be fixed more than once, if so... it wasn't really fixed)</p>

<p>PowerShell won't run commands in the current folder by default. Just like on Unix-likes you have to prefix the command with <code>.\</code> or <code>./</code>, so the following should work:</p>

<pre><code>.\ex.py
</code></pre>

<p>That's assuming Python is installed in a way that you can run commands like that, which must include <code>.py</code> in <code>$Env:PATHEXT</code> and a file association for <code>.py</code> files.</p>

<p>If there is just a file association but <code>.py</code> is not in <code>$Env:PATHEXT</code> you're going through <code>ShellExecute</code> (you can also enforce this with <code>Invoke-Item</code>) and thus the interpreter cannot live in the same console as your PowerShell session. The interpreter will run, but in a separate window.</p>

python powershell