Cant install pygame [duplicate] - python

This question already has answers here:
Unable to install pygame on Python via pip (Windows 10)
(6 answers)
Closed 2 years ago.
So I've got a bit of an issue with python and/or pip...
Python, when asked to download pygame in CMD with py -m pip install -U pygame --user, gives me this error:
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\gary\AppData\Local\Temp\pip-install-1zalja6w\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\gary\AppData\Local\Temp\pip-install-1zalja6w\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\gary\AppData\Local\Temp\pip-install-1zalja6w\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\gary\AppData\Local\Temp\pip-install-1zalja6w\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.
It seems to download the files just fine but does NOT like to continue after that. I'm running python 3.8. And yes, Python is installed in the PATH variable.
I feel like this could be a really stupid issue and I've just overlooked something but I cant seem to find anything that helps.
-----edit-----
I've worked out a bit of a solution - just download and use python 3.7 instead of 3.8 and that seems to work better.

Assuming you're using an IDE with the ability to automatically install imports (PyCharm for example) you can just set your IDE's current interpreter to python 3.7.4 and use it to install pygame instead of using pip. The problem has something to do with the pygame install not working with python 3.8 so either revert your interpreter, role back to python 3.7 or wait for pygame to get updated

Related

Question about installing packages on Python 2.7

I am new to python and I am really confused about lot of things. I am developing my project mainly in PHP but as my host is unable to provide me access to v8js I have to use python to accomplish my tasks.
What I don't understand is:
On my server is running python 2.7, and If I use pip to install latest version of some package, will it install version that will work with python 2.7 or it will install it even if it is meant to run only in python 3?
I am trying to install and use https://pypi.org/project/cfscrape/ but I can't force it to work, but when try it on Repl.it it is working without any problem.
So I guess that something is not right on my server but don't know what, as I just used pip install cfscrape and it intalled that package.
Edit:
Do you think that this error could be result of using python 2 or this is not related to python version in use? All depadances are intalled
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 151, in _run_module_as_main
mod_name, loader, code, fname = _get_module_details(mod_name)
File "/usr/lib64/python2.7/runpy.py", line 101, in _get_module_details
loader = get_loader(mod_name)
File "/usr/lib64/python2.7/pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "/usr/lib64/python2.7/pkgutil.py", line 474, in find_loader
for importer in iter_importers(fullname):
File "/usr/lib64/python2.7/pkgutil.py", line 430, in iter_importers
import(pkg)
File "main.py", line 3, in
test = scraper.get("https://www.klix.ba/koronavirus-u-bih").content
File "/home/admin/.local/lib/python2.7/site-packages/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/home/admin/.local/lib/python2.7/site-packages/cfscrape/init.py", line 129, in request
resp = self.solve_cf_challenge(resp, **kwargs)
File "/home/admin/.local/lib/python2.7/site-packages/cfscrape/init.py", line 204, in solve_cf_challenge
answer, delay = self.solve_challenge(body, domain)
File "/home/admin/.local/lib/python2.7/site-packages/cfscrape/init.py", line 292, in solve_challenge
% BUG_REPORT
ValueError: Unable to identify Cloudflare IUAM Javascript on website. Cloudflare may have changed their technique, or there may be a bug in the script.
On Repl.it it is working and on my server it is not
Most Python developers install more than one version of Python. This may be either due to the fact that the OS includes an old Python distribution or the developer himself/herself works on projects having different Python versions.
Running the pip executable directly with more than one Python distribution on a system is unpredictable and ambiguous. You can get some insight into what pip is actually executing using which command in Linux:
❯❯❯ which pip
/home/abhishek/software/miniconda2/envs/quantum/bin/pip
❯❯❯ which pip2
/home/abhishek/.local/bin/pip2
❯❯❯ which pip3
/home/abhishek/software/miniconda2/envs/quantum/bin/pip3
A better way to use pip is to explicitly specify the Python executable you want to use. This will make sure pip will use the python version you specified
❯❯❯ python -m pip # will use whatever python version this alias points to
❯❯❯ python2 -m pip
❯❯❯ python3 -m pip
PS: Python 2 is already depreciated. It is strongly recommended to use Python 3 for all use-cases.

Python 2.7 : LookupError: unknown encoding: cp65001 [duplicate]

This question already has answers here:
Windows cmd encoding change causes Python crash
(10 answers)
Closed 7 years ago.
I have installed python 2(64 bit), on windows 8.1 (64 bit) and wanted to know pip version and for that I fired pip --version but it is giving error.
C:\Users\ADMIN>pip --version
Traceback (most recent call last):
File "c:\dev\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\dev\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\dev\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\dev\python27\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "c:\dev\python27\lib\site-packages\pip\vcs\mercurial.py", line 10, in <module>
from pip.download import path_to_url
File "c:\dev\python27\lib\site-packages\pip\download.py", line 35, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "c:\dev\python27\lib\site-packages\pip\utils\ui.py", line 51, in <module>
_BaseBar = _select_progress_class(IncrementalBar, Bar)
File "c:\dev\python27\lib\site-packages\pip\utils\ui.py", line 44, in _select_progress_class
six.text_type().join(characters).encode(encoding)
LookupError: unknown encoding: cp65001
Note : The same command works fine for python 3. I have uninstalled both and installed again but still no success.
The error means that Unicode characters that your script are trying to print can't be represented using the current console character encoding.
Also try to run set PYTHONIOENCODING=UTF-8 after execute pip --version without reloading terminal if everything going well add PYTHONIOENCODING as env variable with value UTF-8. See How to set the path and environment variables in Windows article to get info how to add Windows variable.
NOTE: For PowerShell use $env:PYTHONIOENCODING = "UTF-8"
Also you can try to install win-unicode-console with pip:
pip install win-unicode-console
Then reload your terminal and try to execute pip --version
However you can follow suggestions from Windows cmd encoding change causes Python crash answer because you have same problem.
First of all you need to upgrade your pip.
You can do this in Windows by:
python -m pip install -U pip
Then go manually to your script folder, enter command line from that folder (you can do this by clicking shift + right mouse button -> Open console window), and then you should use one of this commands.
pip -V
pip --version
This will result in
pip 7.1.2 from c:\python27\lib\site-packages (python 2.7)
If you still have trouble, you can try to remove your current Python PATH, and add a new one to Python 2.7.

Error installing pyflycapture2 on Windows

I am attempting to install this https://github.com/jordens/pyflycapture2 python binding on my Windows machine. The readme only has instructions on how to do it for Linux systems, but I imagine the library should still work.
I am able to run "python setup.py install" and it seems to successfully complete, but when I try to run "python test_flycapture2.py" I get this error:
C:\Users\clinic\Desktop\pyflycapture2>python test_flycapture2.py Traceback (most recent call last):
File "test_flycapture2.py", line 20, in <module>
import flycapture2 as fc2
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
This seems to imply that flycapture2 wasn't installed correctly. When I instead just open a python session and do "import flycapture2" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
Have I done something wrong with the installation process or does pyflycapture2 just not work with Windows?
A dumb solution that's worth a try. There are chances that the DLL are searched directly from where you're starting the python script. So if you have the dll somewhere on your computer, copy it along where you have your test_flycapture2.py.
But given the fact that the setup.py file has a whole bunch of absolute paths in there, I would not place my hopes too high. You can also try to install FlyCapture 2 at the exact same path, run python setup.py bdist_wheel (you will need to install wheel first with pip) in the pyflycapture2 folder, and see if that succeeds.
If it does, try installing the generated wheel (that will be in dist/ subfolder) by doing pip install dist/pyfly....wheel and test again.
Hope this helps
I'm answering this mostly because I found another post where the same question had been posted but the original problem was never answered.
How do I run an installed Python module on Windows?
In the comments, the original poster says that it suddenly started working. I found that the solution was simply to restart my computer. I have now attempted this on two computers and this worked for both of them.

Syntax error while installing pdfminer using python

I want to use the pdfminer for extracting the text info. I have downloaded the pdfminer-20131113. I have installed the python in C:\python34.
Now using cmd, I am setting the path to the setup.py file of pdfminer.
and running the following command.
python setup.py install
But I am getting the below error.
> D:\pdfminer-20101226>python setup.py install
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from pdfminer import __version__
File "D:\pdfminer-20101226\pdfminer\__init__.py", line 4
if __name__ == '__main__': print __version__
^
SyntaxError: invalid syntax
It seems to be some error in the setup.py file of pdfminer, which I am not sure how to resolve.
Also, I saw a pdf2txt.py file in the build folder of pdfminer. I tried to use that also as pdf2txt.py -o output.html pdffilename.pdf (with full path). but instead of converting it. it opens the pdf2txt.py file.
The PDFMiner project homepage states:
Written entirely in Python. (for version 2.4 or newer)
and further down:
Install Python 2.4 or newer. (Python 3 is not supported.)
so you'll have to install Python 2 to run this project.
Alternatively, you could try the Python 3 port, pdfminer3k; it hasn't seen any updates in 20 months, while PDFMiner does have more recent releases, so your mileage may vary.
This should solve your problem in Python 3
pip install pdfminer.six
pdfminer.six is a fork with Python 2+3 support using six. Last commit was 15 days ago.

MySQLdb installation troubles [duplicate]

This question already has answers here:
installing MySQLdb for Python 2.6 on OSX [duplicate]
(4 answers)
Closed 9 years ago.
*My larger problem is that I cannot launch a web application using dev_apperver.py from my command line*
However, I also cannot install MySQLdb as well.
Joes-MacBook-Pro:MySQL-python-1.2.3 MoeJancini$ python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/MoeJancini/Desktop/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/MoeJancini/Desktop/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Joes-MacBook-Pro:MySQL-python-1.2.3 MoeJancini$
I have looked at similar questions an navigated other forums but I still cannot get past the setup.py build command. Explicit instructions on how to get MySQLdb working would be useful since I'm a noob. Thank you
It depends on what your source for MySQL is. If you're using MacPorts, you may find that you have to use mysql_config5in order for it to work. Edit site.cfg so that it has the right path. Then again, if you're using MacPorts, you should just sudo port install py-mysql and that will install it for you.
So if you're not using MacPorts, you're probably using the mysql.com packages. In that case, you need to install their Connector/C package, which includes development headers and libraries and mysql_config.

Categories

Resources