Can't start PyGame Zero (pgzrun) from cmd - python

I can't start PyGame Zero window from cmd. According to book I bought my kid, I suppose to start it with
pgzrun test.py
Unfortunteally what I get is:
'pgzrun' is not recognized as an internal or external command,
operable program or batch file.
As a Python begginer I started with checking my python and pygame lib:
C:\Users\mikol\OneDrive\python\examples\asteroids>python --version
Python 3.10.9
C:\Users\mikol\OneDrive\python\examples\asteroids>pip show pygame
Name: pygame
Version: 2.1.2
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: pygame#pygame.org
License: LGPL
Location: c:\users\mikol\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages
I have also double confirmed adding
c:\users\mikol\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages
to PATH variable (using Win 11). Am I missing something?

Related

F2 rename variable doesn't work in vscode + jupyter notebook + python

I can use the normal F2 rename variable functionality in regular python files in vscode. But not when editing python in a jupyter notebook.
When I press F2 on a variable in a jupyter notebook in vscode I get the familiar change variable window but when I press enter the variable is not changed and I get this error message:
No result. No result.
Is there a way to get the F2 change variable functionality to work in jupyter notebooks?
Here's my system info:
jupyter module version
(adventofcode) C:\git\leetcode>pip show jupyter
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter#googlegroups.org
License: BSD
Location: c:\users\johan\anaconda3\envs\adventofcode\lib\site-packages
Requires: ipykernel, qtconsole, nbconvert, jupyter-console, notebook, ipywidgets
Required-by:
Python version:
(adventofcode) C:\git\leetcode>python --version
Python 3.10.0
vscode version:
1.63.2 (user setup)
vscode Jupyter extension version (from the changelog in the extensions window):
2021.11.100 (November Release on 8 December 2021)
Notice that you put up a bug report in GitHub and see this issue: Renaming variables didn't work, the programmer replied:
Some language features are currently not supported in notebooks, but
we are making plans now to hopefully bring more of those online soon.
So please wait for this feature.
I am able to rename variables in one cell by:
Select the variable
Right click and choose "Change All Occurrences"
Change the variable name
Ctrl + F2 ~ Change All Occurrences

what can i do to solve Webots error message

I'm new to webots program and I'm building a new robot controller, but when I hit the start simulation button, it gives me this error :
WARNING: "python3.8.exe" was not found.
Webots requires Python version 3.7 or 2.7 (64 bit) from python.org in your current PATH.
To fix the problem, you should:
1. Check the Python command set in the Webots preferences.
2. Check the COMMAND set in the [python] section of the runtime.ini file of your controller program if any.
3. Fix your PATH environment variable to use the required Python 64 bit version (if available).
4. Install the required Python 64 bit version and ensure your PATH environment variable points to it.
The first thing I recommend to start with is to download Python 3.7. in the documentation https://cyberbotics.com/doc/guide/using-python it is claimed that Webots supports python 3.7 (I think you are using windows). Python 3.8 support is only specified for MacOS and Ubuntu. Download link for Python 3.7: https://www.python.org/ftp/python/3.7.7/python-3.7.7-amd64.exe.
When installing, be sure to specify that python should be added to the Path variable (I have circled this field in the figure below with a red rectangle). After installing python, you must restart Webots.
Also using the Windows command line, try running Python using the "python" command, also in the settings in Webots: Tools-Preferences (see the window below) the command that runs Python on your computer is specified. The command to run Python from the command line and the command to run Python specified in Webots-Preferences must match.

Where is "Script" in Atom?

I am importing plotly.offline in my basic.py file, but when i run this basic.py in the platform-ide-terminal, an error comes up and says, ImportError: No module named plotly.offline.
I am sure plotly is pip installed. When i checked it in the default Terminal in my Mac,
pip show plotly
it reads,
Name: plotly
Version: 4.3.0
Summary: An open-source, interactive graphing library for Python
Home-page: https://plot.ly/python/
Author: Chris P
Author-email: chris#plot.ly
License: MIT
Location: /Users/Lorentz/opt/anaconda3/lib/python3.7/site-packages
Requires: retrying, six
Required-by: dash, chart-studio
My default python in Terminal is 3.7.
So i am trying to set the default python of my Atom to 3.7. I googled and my answers are suggesting to set it through Atom→Preferences→Open Config Folder, and open.atom/packages/script/lib/grammars/python.coffee. This is from the official site https://atom.io/packages/script
But my problem is, under packages, i can't locate script.
i then tried to locate it from top menu, still no luck.
Would anyone please tell me where to locate the python.coffee file? or where actually is this "script"?
Go here and search for script. When it is found click install. Or go here and click install.
There is a file named init.coffee in the home/.atom directory. I don't know of a python.coffee file.

Checking Pygame Version

I'm very new to both Python and Pygame. I have Python 3.5.1 32-bits installed on Window and Pygame 1.9.2 Python 3.5 installed as well. But in case if I forget, is there a way to check the pygame version I have installed from either command line or Python IDLE.
For Python, I use python -V
But for Pygame, I don't know how to.
Use this: pip show <pack_name>
Alternative:
pip freeze | grep <pack_name>
I know this question is a year old and has an accepted answer but I've stumbled upon another way to check the version while researching.
You basically import pygame from the command line and type this code
pygame.version.ver
or
pygame.version.vernum
The first one returns the version as a string and the second one returns it as a tuple of integers.
I found this from here
and I know this might be unnecessairy but I wanted to include it anyway.
pip show pygame // command to check your pygame details
output:
Name: pygame
Version: 1.9.4
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: Pete Shinners, Rene Dudfield, Marcus von Appen, Bob Pendleton, others...
Author-email: pygame#seul.org
License: LGPL
Location: /home/linux/anaconda3/lib/python3.6/site-packages
Requires:
Required-by:

Livewires + Pygame Error

So I am running Windows 8 with python 3.3 installed. I have livewires and pygame installed.
But when I run the code:
from livewires import games
games.init(screen_width = 640, screen_height = 480, fps = 50)
games.screen.mainloop()
I get an error saying... ImportError: No module name 'pygame.image'.
Does anyone know how to fix this?
Did you install pygame in the file directory of the python interpreter? But anyway pygame is not available for python 3.3 at the moment. If you want to use python 3 for coding, I would recommend 3.1.1 or 3.2, and use python 2.7.12 to compile them into an .exe file with pyinstaller, because pip is not compatible with 3.1.1 and 3.2. You can also write the code in python 2. I would recommend 2.7.12
If you read the README.md file in the distro's module directory, you'll see that it was committed on September 25, 2013 and specifically states:
You will need Python to use the package. Python can be obtained from: http://www.python.org/download/. If you're installing for the first time, we recommend you use Python 2.2.3
I think it's quite likely that livewires will not work with Python 3.

Categories