How to install pygame in Windows 10 for python 3.9? - python

I have tried everything
Here are some of the methods I have tried
C:\Users\win 10\AppData\Local\Programs\Python\Python39> python -m pip install pygame-1.9.6-cp27-cp27m-win_amd64.whl
The following error is prompted:
ERROR: pygame-1.9.6-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.
C:\Users\win 10\AppData\Local\Programs\Python\Python39> pip install pygame
The following error is prompted:
ERROR: Command errored out with exit status 1:
command: 'c:\users\win 10\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\win 10\\AppData\\Local\\Temp\\pip-install-l782i464\\pygame\\setup.py'"'"';
__file__='"'"'C:\\Users\\win 10\\AppData\\Local\\Temp\\pip-install-l782i464\\pygame\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\win 10\AppData\Local\Temp\pip-pip-egg-info-1zl98t9z'
cwd: C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\
Complete output (17 lines):
**WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\win 10\AppData\Local\Temp\pip-install-l782i464\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
What should I do?

You could use the pre-release version that supports Python 3.9.0.
python3 -m pip install pygame --pre --user

Many packages do not have pre-built wheels for Python 3.9 as it is new.
Also pygame-1.9.6-cp27-cp27m-win_amd64.whl is for Python 2.7
Your best bet is to revert to Python 3.8.6 to install pre-built wheel with pip

install pywin32 first ,pip install pywin32.
and then istall pygame pip install pygame
by doing this you shall be able to download it

This is the way i did it.
Open command prompt on windows and type:
py -m pip install -U pygame --user
Then afterwards to test it out try this small game:
py -m pygame.examples.aliens

With reference to #ViaxCo answer at above for pre-release version installation, which could be for Linux/ macOS, below is another option for Windows, in case 'python3' causing "python was not found error". My installed python version is 3.9.6
python -m pip install pygame --pre --user

Related

How to install a package from git into a specific directory using pip -t

I have downloaded all of my requirements in AWS Linux + EFS using
pip3 install -t /mnt/efs/fs1/ml/ -r /mnt/efs/fs1/ml/requirements.txt
They get downloaded without an issue and I'm able to call them too. Now I want to install detectron2 but it has to be done separately as it requires torch already in the system.
I install it with:
pip3 install -t /mnt/efs/fs1/ml/ 'git+https://github.com/facebookresearch/detectron2.git'
Even if I have installed torch in above requirements, and able to import it too. I also installed it in the global path too (without -t) but still I'm getting the error:
pip3 install 'git+https://github.com/facebookresearch/detectron2.git'
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/facebookresearch/detectron2.git
Cloning https://github.com/facebookresearch/detectron2.git to /tmp/pip-req-build-bcthhh9q
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nmaxo6d1
cwd: /tmp/pip-req-build-bcthhh9q/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-bcthhh9q/setup.py", line 10, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
What is the problem here? The below command runs perfectly in my system when I don't install requirements.txt with -t flag.
This looks like version issue, version supported for torch and detectron2 should be in sync.You can go through this for details :
https://detectron2.readthedocs.io/en/latest/tutorials/install.html
Found the solution. The PYTHONPATH was pointing to default directory so had to tell the env about the new location of packages.
All you have to do is to run the command in terminal:
export PYTHONPATH="${PYTHONPATH}:/mnt/efs/fs1/ml"
And then use the command as usual. It'll work fine

Unable to install bsddb3 Python package on macOS Catalina 10.15.4

I've used Homebrew to install berkeley-db and am now struggling to install the bsddb3 Python package. Any help would be much appreciated.
bash-3.2$ BERKELEYDB_DIR=/usr/local/Cellar/berkeley-db/18.1.32_1 pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.2.7.tar.gz (437 kB)
ERROR: Command errored out with exit status 1:
command: /Users/ryonlife/.local/share/virtualenvs/peg-scrapy-pegbot-ndRdHu61/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/setup.py'"'"'; __file__='"'"'/private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/pip-egg-info
cwd: /private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/
Complete output (8 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/setup.py", line 42, in <module>
import setup3
File "/private/var/folders/00/9r872f810sz481x6k9pqkldw0000gn/T/pip-install-03k5olgq/bsddb3/setup3.py", line 354, in <module>
db_ver = (int(fullverstr[0]), int(fullverstr[2]))
ValueError: invalid literal for int() with base 10: '.'
Trying to use the Berkeley DB you specified...
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The trick for me was using Homebrew to install berkeley-db#4, rather than berkeley-db.
brew install berkeley-db#4
BERKELEYDB_DIR=$(brew --prefix berkeley-db#4) pip install bsddb3
Do not report this issue to Homebrew/brew or Homebrew/core!
Error: You are using macOS 11.1.
We do not provide support for this pre-release version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this pre-release version.

How do I install scientificpython package successfully on Ubuntu 18.04?

I have installed Python 3.7.6 on my Ubuntu 18.04 system. I am trying to install package called "scientificpython" but consistently getting the following error message.
(base) jit#jit-VirtualBox:~$ pip install scientificpython
Collecting scientificpython
Using cached ScientificPython-2.9.4.tar.gz (688 kB)
ERROR: Command errored out with exit status 1:
command: /home/jit/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o8a8hyd1/scientificpython/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o8a8hyd1/scientificpython/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-o8a8hyd1/scientificpython/pip-egg-info
cwd: /tmp/pip-install-o8a8hyd1/scientificpython/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-o8a8hyd1/scientificpython/setup.py", line 72
print "netCDF not found, the netCDF module will not be built!"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("netCDF not found, the netCDF module will not be built!")?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How do I resolve this problem?
Based on your traceback and the ScientificPython home page:
Therefore ScientificPython can be used only with Python 2.7 and NumPy 1.8, but not with later releases of either software.
You are using Python 3.7.6, which does not recognize print as a statement as it existed in Python 2, for starters.
You can install Python 2 from source, or use a tool such as pyenv to manage multiple Python versions alongside each other.
Try to install ScientificPython by specifying the version
Command:
pip install ScientificPython==2.9.4
Or Try:
python -m pip install ScientificPython==2.9.4
If problem still persist, then try to download the tar file of the package then install it manually. Available links are provided.
https://files.pythonhosted.org/packages/a2/8e/6306c88c0e937af38ed3a40e2a08caf30c53ad7f33e2928f14ae2cf53961/ScientificPython-2.9.4.tar.gz
Or
https://src.fedoraproject.org/lookaside/extras/ScientificPython/ScientificPython-2.8.1.tar.gz/
Or
https://osdn.net/frs/g_redir.php?m=kent&f=anuga%2Fanuga_support_software%2Fubuntu_8.10%2FScientificPython-2.9.0.tar.gz
But ScientificPython works only with Python version 2. So it is recommended to use the alternative package called Scipy.
Command:
pip install scipy
Or
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
I hope it would resolve the error.

error command errored out with exit status 1 pip install [duplicate]

This question already has answers here:
pip3 install mysql-python failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/
(2 answers)
Closed 2 years ago.
I use python vitrualenv and when I want to install any packages by pip install <package name> I take that error:
ERROR: Command errored out with exit status 1:
command: /home/user/project/some_project_name/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sifdsjjx/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sifdsjjx/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-sifdsjjx/MySQL-python/pip-egg-info
cwd: /tmp/pip-install-sifdsjjx/MySQL-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-sifdsjjx/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-install-sifdsjjx/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I use python 3.7.0
pip 20.0.2
Try to upgrade setuptools:
pip install --upgrade setuptools
UPDATE
As mentioned in the comments, you are attempting to install MySQL-python which is a very old package (last release was made back in 2014).
You can however install a more recent one, called MySQLdb which is a thin python wrapper around C module which implements API for MySQL database:
pip install mysqlclient
Did you install the SQL client dev pacakge on your system?
sudo apt install libmysqlclient-dev
if you are using mariadb, the drop in replacement for mysql, then run
sudo apt install libmariadbclient-dev
then try again

pip3 install mysql-python is failing on Mac

There are a lot of similar question but all of them has different solution. And none of them work for me.
I'm trying to install Mysql connector for Django project but it gives below error.
First I have installed latest version of Django.
Then install mysql with below code
brew install mysql - Worked fine.
Then this is the code which I'm trying install connector.
pip3 mysql-python. Was using easy_install mysql-python before but both of them are not working.
Python Version: 3.8.0
Django Version: 2.2.7
MySql Version: 8.0.18
pip3 mysql-python gives this error:
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/pip-egg-info
cwd: /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
You're installing the wrong lib, you should be using mysqlclient.
pip install mysqlclient
I have a django project on my Mac using it.
Edit
You should be using virtualenv when installing pip packages.
This command worked for me
pip3 install mysqlclient==1.4.2.post1

Categories

Resources