Note that there are some explanatory texts on larger screens.

plurals
  1. POPython can't handle importing via command-line
    primarykey
    data
    text
    <p>My python scripts run fine from IDLE, but when I try to run them from the command-line, things go wrong. First I had trouble importing pygame, but I added C:\Python27\Lib\site-packages to the PYTHONPATH environment variable and all was well, I thought. However, now when I attempt to run something from the command line, I get this:</p> <pre><code>C:\Users\Ian Sinke\Documents\Pong&gt;python pong.py 'import site' failed; use -v for traceback Traceback (most recent call last): File "pong.py", line 3, in ? import pygame File "C:\Python27\Lib\site-packages\pygame\__init__.py", line 27, in ? import sys, os, string File "C:\Python27\Lib\os.py", line 63, in ? import ntpath as path File "C:\Python27\Lib\ntpath.py", line 401 backslash, dot = (u'\\', u'.') if isinstance(path, unicode) else ('\\', '.') ^ SyntaxError: invalid syntax </code></pre> <p>Any ideas?</p> <p>This is not a localize problem; when I try to run another script from the command line, I get this:</p> <pre><code>C:\Users\Ian Sinke\Documents&gt;python app.py 'import site' failed; use -v for traceback Traceback (most recent call last): File "app.py", line 4, in ? import urllib2 File "C:\Python27\Lib\urllib2.py", line 92, in ? import base64 File "C:\Python27\Lib\base64.py", line 346 with open(args[0], 'rb') as f: ^ SyntaxError: invalid syntax </code></pre> <p>and that syntax is definitely OK...</p> <p>Pong.py begins like this:</p> <pre><code>#import sys import math import pygame import time from pygame.locals import * # Helper functions def centerdist(paddletop, balltop): return balltop - paddletop - 30 # Constants BLACK = 0, 0, 0 pygame.init() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload