I want to install pygame on python. I have ubuntu 20.04 (which has python3.8 already installed) and Anaconda.
pip is connected to Anaconda: which pip shows it's at /home/mohammad/anaconda3/bin/pip.
I use pip to install pygame on Anaconda. But pip install pygame shows error. How can I install pygame on Anaconda?
I can simply install pygame by deactivating Anaconda Enviroment and using pip which installs it on system python (It shouldn't have any problem). But I want to have pygame on Anaconda.
I don't really know where the problem is.
$ pip install pygame
Collecting pygame
Using cached pygame-1.9.6.tar.gz (3.2 MB)
ERROR: Command errored out with exit status 1:
command: /home/mohammad/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-z7x7jtmx/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z7x7jtmx/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 /tmp/pip-pip-egg-info-ctnap_n6
cwd: /tmp/pip-install-z7x7jtmx/pygame/
Complete output (25 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Hunting dependencies...
WARNING: "sdl-config" failed!
WARNING: "pkg-config freetype2" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
python3 -m pip install pygame==2.0.0.dev6
Please try running the above mentioned code on your platform.
There isn't a build of 2.0.0.dev3 for Python 3.8. Python 3.8 wasn't out when dev3 was released. You want the latest, so change your command to that .
However , if that also doesn't help you as well , try sudo apt install python3-pygame
Related
I have been trying to install psycopg2 (pip install psycopg2), but I keep getting this error.
I have also tried with: pip install psycopg2-binary but I'm getting the same error.
Here is the error message:
ERROR: Command errored out with exit status 1:
command: 'c:\users\viktor\pycharmprojects\wemport\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycop
g2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycopg2\\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\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl'
cwd: C:\Users\Viktor\AppData\Local\Temp\pip-install-015ceiei\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info
writing C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How to fix that?
The following will install prebuilt binaries for windows. It's worked for me on 3.9. You can uninstall pipwin after install psycopg2.
pip install pipwin
pipwin install psycopg2
Optional after psycopg2 installed:
pip uninstall pipwin
if u use linux
You need to make sure that you install wheel model
and Try that
sudo ./venv/bin/python -m pip install wheel
after that install psycopg2 and psycopg2-binary
sudo ./venv/bin/python -m pip install psycopg2
sudo ./venv/bin/python -m pip install psycopg-binary
I am trying to host a Django app on Heroku. The app works fine on my computer as long as I don't use django-heroku (because I can't install it), and it works fine on Heroku as long as it does have django-heroku. This is not a pressing issue, but it is sort of annoying to have to remove django-heroku to make edits on my computer, and then have to re-insert it before pushing to heroku.
The ideal solution would be to get django-heroku installed on my computer.
Specifications:
Mac running macOS
Conda environment, python 3.7 and 3.8
Here is what I have found so far:
pip 20.0.2 from /Users/lucas/opt/anaconda3/lib/python3.7/site-packages/pip (python 3.7):
Cannot install django-heroku (See error below)
pip 20.1.1 from /Users/lucas/Library/Python/3.7/lib/python/site-packages/pip (python 3.7):
Can install django-heroku, however:
Gives me this warning: (still installs without any problems)
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
running the script with all pythons in the environment say no module called django_heroku
The first version of pip I specified that couldn't install django-heroku gives this error:
pip install django-heroku
Collecting django-heroku
Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
Collecting psycopg2
Using cached psycopg2-2.8.5.tar.gz (380 kB)
ERROR: Command errored out with exit status 1:
command: /Users/lucas/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/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/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info
cwd: /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/
Complete output (23 lines):
running egg_info
creating /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info
writing /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I'm not an expert on how things like this work, so I included as much information as I could. I appreciate any help you can give on this.
First, django-heroku is no longer maintained, so my advice is to not use it.
Your problem, though is with psycopg2, as the error mentions, not django-heroku directly. Since django-heroku depends on psycopg2, installing psycopg2-binary probably won't help - and there can be issues with this as well, it's not suitable for serving your site from, although you're probably not doing that on OS X.
To get it working, you need to install the PostgreSQL libraries:
brew install postgresql
Depending on a few things, you may also have problems after that. If you see any errors about gcc and ssl, you can try running:
setenv LDFLAGS "-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
For fish, or if you running bash:
export LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
It can be tricky, so that may not be enough.
I am trying to install openbabel with pip on a linux computer without root access and also using a virtual environment. I run the following command
pip install openbabel --user --log LOG
and then I get the following error:
Collecting openbabel
Using cached openbabel-2.4.1.tar.gz (74 kB)
Building wheels for collected packages: openbabel
Building wheel for openbabel (setup.py) ... error
ERROR: Failed building wheel for openbabel
Running setup.py clean for openbabel
Failed to build openbabel
Installing collected packages: openbabel
Running setup.py install for openbabel ... error
ERROR: Command errored out with exit status 1: /users/name/env_for_pymatgen/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b51wnefv/openbabel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b51wnefv/openbabel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4207icvx/install-record.txt --single-version-externally-managed --compile --install-headers /users/name/env_for_pymatgen/include/site/python3.6/openbabel Check the logs for full command output.
The main problems seems to be
Error: SWIG failed. Is Open Babel installed?
You may need to manually specify the location of Open Babel include and library directories. For example:
python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib
python setup.py install
I see many people had similar issues with setup.py and they are advised to go to the directory and run the same command again, but I don't know what directory I should go to...
EDIT
Would it work if I download openbabel from github and give the path to it?
From my experience, instead of pip install <package_name>, download a wheel file from here which has python binaries built from source code found on PyPI.
After that, open a terminal where you downloaded .whl files and then type :
pip install nameOfYourFile.whl
in my case it's :
pip install openbabel-3.1.1-cp38-cp38-win32.whl
EDIT: be sure to download a version matching your python version otherwise the package will not install.
EDIT2:
I honestly didn't notice that the answer is focused on Linux, so to answer your question, your most reliable option is to build it from source with the python bindings and swig flags enabled, this can be done by following the compiling instructions.
Those instructions still work for the latest version of openbabel in the GitHub repo as of the date of this edit, and i could successfully compile a working openbabel with the python bindings (pybel) on Ubuntu 21.10.
I've tried to type this command:
pip3 install --user psycopg2 psycopg2-binary
Bash answers:
ERROR: running install
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-record-lkzzuu55/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/
You're not being able to install psycopg2 as the gcc compiler in your device is either outdated and not compatible to install and run it, or it does not exist.
if you just run pip install psycopg2-binary, then it will work on your development and testing environment, however it is not recommended for production.
To install psycopg2, make sure that you have gcc installed in your device by running-
gcc --version
gcc where
If it is not installed, then install it by referring to the guide here-
Installing GCC in Mac
I hope this helps. :)
after successfully installed python and pip, this command should work:
pip install psycopg2
I am having significant trouble installing psycopg2 in OSX. After installing Postgresql 9.5.4_1 using homebrew I attempted to install psycopg2 in my virtual environment:
pip install psycopg2
I have also added pg_config to my path using PATH=$PATH:/usr/local/Cellar/postgresql/9.5.4_1/bin/pg_config
Upon excecution I receive a number of errors including:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
And
Failed building wheel for psycopg2
And
Command "/Users/*username*/.virtualenvs/report/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-8gbk007q-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/*username*/.virtualenvs/report/bin/../include/site/python3.5/psycopg2" failed with error code 1 in /private/var/folders/9p/3_wdgjzd03d6bw1p_c9rrt6c0000gp/T/pip-build-cuplxne2/psycopg2/
Attempting to build from source results in similar errors...
Previous research and attempted solutions:
"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip
How to install Psycopg2 for Python 3.5
How to install psycopg2 with "pip" on Python?
Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system
Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7
Thanks for any assistance you can provide!
My way for macosx sierra
Install psycopg2 globally, and then use it in virtualenv
pip3 install psycopg2
workon my_env #i use virtualenvwrapper
toggleglobalsitepackages #Enable global site-packages
In my case psycopg2 normally installed as global package, but isn't installed in virtualenv
Mine broke with the Sierra 10.12.2 update. Reinstalled/updated the command line tools and psycopg2 installed correctly.
xcode-select --install
This seems to be an issue with Homebrew's update of for OSX sierra. I was able to finally fix this issue by uninstalling and reinstalling python 3.5 and postgresql with homebrew and then trying to install psycopg2 again.