What can I do to install Pygame? [duplicate] - python

This question already has answers here:
How to install pygame?
(4 answers)
Unable to install Pygame using pip
(27 answers)
Closed 22 days ago.
I can't use pygame package in Pycharm. I have installed it with pip but I can not use it. When I tried to install it from the error that appeared in the IDE or from 'Python Packages', it gave me an error. I also tried pip install pygame --pre and it's not working. It says that 'Requirement already satisfied:' but I still can not use it. What should I do?

You should be able to left click on the module. It will display a download packages button. You need internet but should be able to download it. You don't to use the command prompt to install packages. That is only for the python IDLE.

Go here and click install. Pycharm using his own registry of packages.
https://imgur.com/a/AZvsBxJ

So, you're using PyCharm, it likely means it has created a new virtual environment when you created your project, to install packages in that environment it's easiest to either use PyCharm's Package Manager or Terminal. In the case of using Python 3.11 you'd need to supply the --pre flag when installing pygame because the full release of 2.1.3 has not yet been released and 2.1.3.dev8 which is a pre release is the latest one that has 3.11 wheels for installation. More information about that particular thing can be found here: https://stackoverflow.com/a/74188087/14531062
So, on PyCharm you'd want to use the Terminal:
When you switch to it, you'll likely find that it basically is PowerShell (unless you have changed it to use CMD which I doubt) (you'll see PS at the start of each line) so the easiest steps to install pygame would be to type in these commands in this order (press the enter key after each line):
cmd
venv\scripts\activate
pip install pygame --pre
After running these commands pygame should be installed in the correct environment and you should be able to import it without any issues.
Screenshot of how it might look when you follow the steps:

Related

I am trying to install pygame using pycharm terminal but I get this error [duplicate]

This question already has answers here:
Unable to install Pygame using pip
(27 answers)
Closed last month.
I was trying to install pygame module using pycharm's terminal by typing "pip install pygame" but I am getting this errorinstallation error and yes I have tried running pycharm with admin perms and stuff but it did not work, if you can help then ty!
I just tried to use pygame by typing in my .py file "import pygame" but it say "no module called pygame" and I was simply trying to get a blank window
just upgraded Python to latest version updated pip by using,
pip install --upgrade pip
after that simply run
pip install pygame
Make sure you are using the correct version of python and pygame that both are compatible with each other.
Seems like you don't have admin privilege. Try to open the command prompt with Run as administrator mode or pip install numpy --user

I am trying to run a program which I have cloned from GitHub and followed every step that they told but I am having this problem running it in CMD [duplicate]

This question already has answers here:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
(22 answers)
Closed 1 year ago.
F:\Hacking\GitHub\sherlock>python3 -m pip install -r requirements.txt
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
You provided limited information
First off check if you have installed python: I suggest using Anaconda. It's quite straightforward.
After that create a conda (Anaconda) environment (imagine it as a space that you can have different versions of packages- Python packages tend to be very dependent on the version of related packages, conda usually check the compatibility of them when you are installing them)
Using pip and conda together can be tricky. I suggest first install the main packages then go for more specialized one, maybe using pip
Try to have an issue on the github page of the project. If the package is popular or fresh, they usually respond fast.

pip install pyodbc is not working on python [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 2 years ago.
I installed Python on my Windows 10 computer
when I try to run my python code
I get error
ModuleNotFoundError: No module named 'pyodbc'
I checked multiple questions here and the solution is to pip pyodbc
I tried that
pip install pyodbc
but i get error
SyntaxError: invalid syntax
I checked similar propblems here and it seems that pip is not installed.
I unistalled and reinstalled python from python.org and still same issue!
any solution?
Edit
I did as suggested to try from command prompt
but still same error
I installed Python with ticking the option to include environment variables option.
Edit 2 :
I think the problem was that I was trying to install from witthin python.
I misunderstood the answers, I have to run pip as an application outside of python. to allocate pop.exe and then do pip install.
You are trying to install the package from python interpreter (IDLE) which is wrong. You should only import package from IDLE terminal (python session) which IDLE has access to.
Try this link to install the package --> https://pip.pypa.io/en/latest/installing/
You would run pip from a shell, not from the IDLE. However, pyodbc requires the Microsoft ODBC Driver. More information about installing the pyodbc module can be seen in this guide. This Stack Overflow answer can also help.
Normally, you run pip from a shell, not from a Python interactive session.
C:\PATHTOPYTHON\python.exe pip install <<SOMEPACKAGE>>
See the following thread, if you want to install from within a Python interactive session.

Install Python packages and directories (windows) [duplicate]

This question already has answers here:
How to change the path of Python in Spyder?
(5 answers)
Closed 4 years ago.
I am new to configuring and setting up Python from scratch.
I have installed Anaconda and I plan to use Spyder for python development. I also have a older version of Python installed on the same machine elsewhere.
I needed to get my hands on a package to use in Spyder which I needed to download and install.
I downloaded and installed pip directly from the website and then I used this in the command line of the older python install to obtain the package I required.
However I don't understand how I go about making this available to Spyder. I believe it works on a folder structure within it's own directory and I am unsure how to change this to get the package I have already downloaded.
I thought I might be able to copy it across, or point it at the directory where the package was downloaded to but I cannot work out how to do this.
I also tried using pip from within Spyder to work but it cannot find it.
Can you please let me know what I need to check?
from the command line can you use pip? Btw I believe python 3 comes with pip included anyway you need to make sure it's in your path
Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
Try to:
Open Anaconda Prompt and then do: pip install whatever - to install wheels
If you want to install spyder the open Anaconda Navigator - and you should be in the home tab - then highlat spyder and press install - thats all.
There are other ways but within spyder ipython console you can install package like.
In [1]: import pip
In [2]: pip.main(['install', 'module-name'])

Python 3.5.1 Pygame Installation

I am trying to install Pygame for Python 3.5.1, but it tells me to upgrade to the new version of pip. "You are currently using 7.1.2, use 8.1.2".
Here is a screen shot of it:
The error clearly states Access Denied.
Try to run cmd/powershell as administrator.
The installation error is not because of pip , though you should still upgrade pip
python -m pip install --upgrade pip
Pygame does not have python3.5 support yet. Check the binaries here
Pygame binaries
Try to use Python version 3.4 or 2.7 and then install pygame.
EDIT
You can find unofficial pygame binaries for several Python versions including Python3.5 here.
So if you do not find the official binary, you could try the appropriate file from the above link.
Note: The binaries given there are whl files. So you need to install them using pip.
Example: Assuming you have 32-bit Python installation, run pip install pygame-1.9.2b1-cp35-cp35m-win32.whl
See this answer for more detailed instructions.
Pip seems to be having a permission problem creating this directory: c:\program files (x86)\python35-32\Lib\site-packages\pygame
Here are some things you can try:
Navigate to that directory and see if it already exists. If it does exist, then try deleting it.
Try running pip as an administrator. Right click the command prompt icon and select run as administrator. Your path variables might not be set for the administrator, so you many need to give the full path for pip. In your python folder, it should be in a folder called scripts.
Since you're using Windows, you can also try the binary installers here: http://www.pygame.org/download.shtml
If nothing works you can try installing a different version of Python. I use Python 2.7.8 with pygame.
It was a problem based on the admin command run program and I figures it out.

Categories

Resources