Как установить pygame в thonny

от admin

InstallingPackages

From the «Tools» menu select «Manage packages. » and follow the instructions.

With pip on command line

  1. From the «Tools» menu select «Open system shell. «. You should get a new terminal window stating the correct name of the pip command (usually pip or pip3 ). In the following I’ve assumed the command name is pip .
  2. Enter pip install <package name> (eg. pip install pygame ) and press ENTER. You should see pip downloading and installing the package and printing a success message.
  3. Close the terminal (optional)
  4. Return to Thonny
  5. Reset the interpreter by selecting «Stop/Reset» from the «Run menu» (this is only required the first time you do the pip install)
  6. Start using the package

Using scientific Python packages

The Python distribution that comes with Thonny doesn’t contain scientific programming libraries (e.g. NumPy and Matplotlib).

Recent versions of most popular scientific Python packages (eg. numpy, pandas and matplotlib) have wheels available for popular platforms so you can most likely install them with pip but in case you have trouble, you could try using Thonny with a separate Python distribution meant for scientific computing (eg. Anaconda, Canopy or Pyzo).

Example: Using Anaconda

Go to https://www.continuum.io/downloads and download a suitable binary distribution for your platform. Most likely you want the graphical installer and the 64-bit version (you may need a 32-bit version if you have a very old system). Note that Thonny supports only Python 3, so make sure you choose a Python 3 version of Anaconda.

Install it and find out where it puts the Python executable (python.exe in Windows and python3 or python in Linux and Mac). For example in Windows the full path is by default c:\anaconda\python.exe .

In Thonny, open the «Tools» menu and select «Options. «. In the options dialog, open the «Intepreter» tab, click «Select executable» and show the location of Anaconda’s Python executable.

After you have done this, the next time you run your program, it will be run through Anaconda’s Python and all the libraries installed there will be available.

Thonny’s main developers are not native English speakers. Feel free to create an issue if you spot a grammar or style error in the wiki.

Установка дополнительных модулей в Python

Все движется, все меняется. Совершенствуется и Python 3. Теперь в него добавлена возможность установки дополнительных модулей с помощью командной строки Windows.

Чтобы установить, например, PyGame, выполните следующие операции:

1. Запустите командную строку Windows

Рис. 1 Командная строка Windows 7

2. Наберите и выполните команду pip install pygame. Все остальное произойдет в автоматическом режиме. Программа сама скачает и установит данный модуль:

installPygame

Рис 2. Установка библиотеки PyGame

Есть только два момента. Первый, это Ваш антивирус. Он наверняка спросит, доверяете ли Вы предложению pip? Смело отвечайте «Да» )

Второе. Python не добавлен в переменную PATH. В этом случае установка будет несколько сложнее — нужно полностью указать путь к pip. У меня, к примеру, Python установлен в папку C:\Python3. Тогда, для установки с помощью pip, мне нужно было бы использовать следующую команду:

Результат будет таким же как и в предыдущем случае.

Проверяем результат. Открываем IDLE и вводим инструкцию import pygame. Если Вы не увидели никаких сообщений об ошибке, то все прошло успешно. Пользуйтесь на здоровье )

pygame error: "ImportError: No module named 'pygame'"

enter image description here

I tried importing pygame in both python 3.4.2 and python 3.6.3 using both pip and pip3 respectively.

In the python 3.4.2 shell:

Traceback (most recent call last) is:
File «», line 1, in
import pygame
ImportError: No module named ‘pygame’

In the python 3.6.3 shell:

Traceback (most recent call last):
File «», line 1, in
import pygame
File «C:\Users\aditya dand\AppData\Local\Programs\Python\Python36\lib\site-packages\pygame__init__.py», line 141, in from pygame.base import *
ModuleNotFoundError: No module named ‘pygame.base’

Those are the errors that occurred.

I also used pygame-1.9.2a0-hg_5974ff8dae3c%2B.win32-py3.4.msi .
It’s showing the header’s file of pygame , but it’s not importing something.

What can I do to solve this?

zx485's user avatar

7 Answers 7

gohlke/pythonlibs/#pygame to find a Windows installer that matches the version of Python you’re running. The current version of pygame is : pygame-1.9.4-cp37-cp37m-win_amd64.whl

Читать:
Почему в таблице эксель цифра ноль исчезает

Move this file to the folder C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts

open cmd and then type:

and then type the command:

Now you have successfully installed pygame package.

open PyCharm File >> setting make sure the «Project Interpreter» has the «pygame» package like the following:

kimmi's user avatar

check if you have added python to path

ans done if any one need help delete all python version from system and install python 3.5.2 from https://www.python.org/downloads/release/python-352/

and search pygame and download pygame‑1.9.3‑cp35‑cp35m‑win_amd64.whl

then go to C:\Users\»your username»\AppData\Local\Programs\Python\Python35\Scripts> in this location in cmd ( command prompt )

type this line and done » pip3 install pygame-1.9.3-cp35-cp35m-win_amd64.whl «

hope this help you

Edit — pygame only works in python >= 3.6.*

If you are using Windows i had the same problem and i know how to fix it, follow the steps:

  1. Go to the pygame website, then go to the downloads page
  2. Once there scroll down to the windows section and copy the bit that it says to put into pip It should start with py
  3. Once this short piece of code is copied, open command prompt (search it on start, it is nothing to do with python)
  4. Open it and paste the line of code, it should say downloading and then installing and just wait a bit for it to finish. Then in the command prompt paste the example.aliens thing in and it should work.
  5. Now the complicated part, open file explorer, go to this pc and search pygame once it has fully loaded, look near the top if the list of things it came up with. There should be 2 thing that are called pygame.
  6. Now leave this open and hold the windows button and press r
  7. Then type %appdata% and press enter

This will open the appdata roming file

Look at the bit at the top that says Appdata > roaming and click on app data

Pls comment if this doesnt make sense or you would like further details

Glitchd's user avatar

Did you install pygame? You need to type pip install pygame or sudo install pygame into terminal. If you are using windows 10, press the windows logo key then type terminal. You can check it’s installed with: pygame -H or pygame help

Psychzander's user avatar

You can either use cmd to install pygame type this pip install pygame (you have to make sure that python is installed) If this doesn’t help Use thonny idle I use it because python doesn’t work with my pc basically Thonny is a python idle which runs without the requirement of python to be installed and you can also install modules using thonny and type python code as well but make sure that if you import a module in thonny that module can be only used in thonny and can’t be used in any other idle unless you install it in cmd but you don’t need it as thonny idle is great so if you want to install modules like pygame in thonny 1) Open thonny 2) click on tools 3) click on open shell There you can type pip install pygame and install it successfully I have a potato pc which can’t run python because it requires service pack 1 windows7 or above I don’t have it I only have windows 7 so I use thonny and use pygame using thonny only. 😀

type this in shell: py -m pip install -U pygame —user user is your cmd user.

How do I use pygame with Thonny?

I downloaded and installed Python and Pygame but whenever I run this:

it gives me this error: ModuleNotFoundError: No module named 'pygame'

how can i fix this?

You probably want to install it using the built in Thonny package manager. I think you will find it under the tools menu. Additionally, Thonny comes with a python installation and does not require a system install of python.

Похожие статьи