If I create a pygame project and add numpy as a package, the console executes “python3 - m poetry add numpy”. I then get an error that ‘NoneType’ object is not subscriptable at venv/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py: 282 in _get_release_info (Line 278: cache_version = str(self.CACHE_VERSION),
If instead I create a python project and I add pygame and numpy as packages, when I run my program I get a runtime error “pygame.error: No available video device”.
Is there some way I can run my program in replit that uses both pygame and numpy?
I can’t seem to access the repl for some reason, I think it’s because it’s on an educational account. Could you paste the code that’s generating the error here?
Also, the error NoneType is not subscriptable means you are trying to use the subscript operator [] on a variable that has None type. You can only use the subscript operator on certain types like arrays or tuples.
A common way this error can occur is through sorting a list incorrectly:
I created my own Pygame repl and tried to use Numpy, but I got the same issue. I think the error ‘NoneType’ object is not subscriptable is actually a bug with the Pygame repl, since the error appears before the main.py file is interpreted. I submitted a bug report.
In the meantime, you could manually install the package. Go to the Shell (it’s next to the console) and type:
pip install numpy
You would still need to have import numpy in your main.py file. And there might be some error messages in the console, but if your code works then just ignore them. You could also clear the console at the beginning of your code so you don’t have to see them:
import numpy, os
clear = lambda: os.system('clear')
# this function will clear the console
clear()
# rest of the code...