8

I'm at the very beginning of learning to code in Python (and first time using Powershell), so I assume my problem is very basic. When I try to run any Python script in PS, I get an error like the one below. The main suggestions I've found online are to (1) make sure I've set execution policy to unrestricted, and (2) edit my Path to include "c:\Python27;c:\Python27\Scripts" I've done both these things. What else should I try?

   PS C:\windows\system32> python
python.exe : Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
At line:1 char:7
+ python <<<< 
    + CategoryInfo          : NotSpecified: (Python 2.7.6 (d...ntel)] on win32:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError


Type "help", "copyright", "credits" or "license" for more information.
9
  • Try running python -v to get verbose output. Do you get the same result when you run python.exe instead of just python? Do you get the same result when you run python in CMD? What is the output of $env:PATH? Commented Mar 13, 2014 at 21:10
  • If Python is writing to STDERR, then PS interprets this as an exception. Type python 2>$null Commented Mar 13, 2014 at 22:28
  • Are you using the ISE? If so, try running from a PowerShell session. Commented Mar 13, 2014 at 22:34
  • If this IS caused by Python writing to STDERR, then this is a duplicate of (stackoverflow.com/questions/1394084/…) and probably many other postings as it's a common issue. Commented Mar 13, 2014 at 22:38
  • One final note - if you are learning PowerShell, check out PowerGui (www.powergui.org), it makes things a lot easier. Commented Mar 13, 2014 at 22:47

1 Answer 1

11

This could be due to a 64bit/32bit mismatch. Try running the python command in "Powershell (x86)" assuming your were using the 64bit "Powershell" or "Powershell ISE".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.