I cannot start any program from PythonStdioGames and get an error, how can I prevent this? - python-3.x

I am relatively new to Python and programming in general and currently learning Python with the book "Automate the boring stuff with Python" by Al Sweigart. As recommended in the book, I wanted to do some programming exercises myself by looking into the module gamesbyexample (https://github.com/asweigart/pythonstdiogames/).
However, whenever I start one of the games I get the following error message in the Terminal:
AdminisatorsMBP:~ simon$ /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/__crashdetector__.py 0.1.5 /Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/alphabetizequiz.py
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/__crashdetector__.py", line 16
except KeyboardInterrupt, EOFError:
^
SyntaxError: invalid syntax
I tried using multiple versions of python, 3.7.7 and 3.8.2, but with both versions, the same message comes up.
How could I get this running properly?

This is a syntax error, which means that you're probably missing something in the code that the compiler was expecting to be there.
If you could please also post the code, we could see what the problem is.

Related

ndarray is not C-contiguous issue by building a free program from source

I'm new for programming languages. I have build Ctrax programe from source, everything work except tracking part. The issue is a picture below:
I used UBUNTU 16.04 , python 2.7.12 and others for the program requirement. According to publisher, he said it could possibly be fixed by adding .ascontiguousarray() after the .astype() call in that final line from the error message. Since you have the code compiling, you could simply try it and see if it works. (https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html)
I tried it but still confuse.
Please suggest, many thanks
This is Ctrax link and requirement: http://ctrax.sourceforge.net/install.html#distutils

building opengm with python3

Hi I'm trying to build opengm with python3, which is allegedly supported. Crosspost to opengm forum here. The reason I ask is that I get an error on "PyInt_FromLong" which is according to this article something that shouldn't come up when porting a c library like opengm to python3. When I changed this to PyLong_FromLong, I ran into another compilation problem down the line from numpy.core.multiarray. Also note that it builds (with the appropriate ccmake options) with Python2 just fine.
My questions are:
1. Has anyone actually successfully build this?
2. Can anyone shed some light as to whether this is something on my end or theirs?
Thanks,
Chris

thrift js:node - Cannot use reserved language keyword: "not"

When converting a thrift object for nodejs:
thrift -r --gen js:node state_service.thrift
The following error is thrown:
[ERROR: /state_service.thrift:33] (last token was 'not') Cannot use
reserved language keyword: "not"
The lines in the code around 33 are:
typedef bool Not
struct Exp {
1: string left
2: Not not
3: BinaryOp op
4: AnyValue right
}
I am using the most recent Thrift version 0.9.2
Try to change the not to something else, i think the problem is that 'not' may have another meaning in the language that you choose to generate.
2: Not not
The solution is to not use the reserved language keyword, as advised by the Thrift compiler. These keywords are reserved for a reason. Thrift is a cross-language tool, and not is indeed a keyword in some of them.
I don't want to change the processing code only because of a faulty js converter.
I beg to differ. Faulty is something that does not work, altough it should. Thrift clearly tells you that what you are about to try is illegal (as of today) and what the problem is.
To put it another way: With Linux, you can put uppercase and lowercase letters in a file name (actually you can put a whole bunch of strange things in, but I'll make it easy). So creating a FILE and a file in the same folder will work perfectly. If you now take your program and run it on Windows, relying on that behaviour, you will sooner or later run into trouble and may start to complain you "dont want to change your processing code only because of that faulty OS".
Note that complaining will not help you out of the pothole, altough the endorphines emitted during that process will make sure you have a fun time. The solution is of course to wait until Microsoft fixed their faulty OS, because you make the rules. Correct?
Of course not. So if you feel the implementation is wrong - fine! This is Open Source, and nobody claimed perfection. You are free to provide a patch, and we will happily review it. But please make sure you tested it with all 20+ languages currently supported by Thrift.

I'm getting an invalid syntax error in configparser.py

I'm trying to get the pymysql module working with python3 on a Macintosh. Note that I am a beginning python user who decided to switch from ruby and am trying to build a simple (sigh) database project to drive my learning python.
In a simple (I thought) test program, I am getting a syntax error in confiparser.py (which is used by the pymysql module)
def __init__(self, defaults=None, dict_type=_default_dict,
allow_no_value=False, *, delimiters=('=', ':'),
comment_prefixes=('#', ';'), inline_comment_prefixes=None,
strict=True, empty_lines_in_values=True,
default_section=DEFAULTSECT,
interpolation=_UNSET):
According to Komodo, the error is on the second line. I assume it is related to the asterix but regardless, I don't know why there would be a problem like this with a standard Python module.
Anyone seen this before?
You're most certainly running the code with a 2.x interpreter. I wonder why it even tries to import 3.x libraries, perhaps the answer lies in your installation process - but that's a different question. Anyway, this (before any other imports)
import sys
print(sys.version)
should show which Python version is actually run, as Komodo Edit may be choosing the wrong executable for whatever reason. Alternatively, leave out the parens and it simply fails if run with Python 3.
In Python 3.2 the configparser module does indeed look that way. Importing it works fine from Python 3.2, but not from Python 2.
Am I right in guessing you get the error when you try to run your module with Komodo? Then you just have configured the wrong Python executable.

I'm getting a SyntaxError in Python 3

I am a beginner in Python. I am using the latest version of Python 3.2 on Windows 7. I found that print, count, raw_input("") and many others are showing errors. Here's an example of the error:
>>> print "Any body to help"
File "<stdin>", line 1
print "Any body to help"
^
SyntaxError: invalid syntax
You're reading Python 2.x material. Find Python 3.x material and read that instead. The language has changed.
Yes, the syntax was changed. Seeing as a lot of the code out there still is not 3.x, I'm guessing you may or may not actually be able to find the equivalent code to what you're looking at in 3.x. So to answer your specific question though you should type prints as follows in python 3.x.
print("Any body to help")
Hope this helps.
Edit: This should help clear up your raw_input as well. Another SO Question

Resources