Unable to install geopandas on python3.9 on macOS Big Sur - python-3.x

I am trying to install geopandas on the machine described above.
This is what I am doing the error I get:
sudo pip3 install geopandas
Collecting geopandas
Downloading geopandas-0.8.1-py2.py3-none-any.whl (962 kB)
|████████████████████████████████| 962 kB 5.0 MB/s
Collecting fiona
Downloading Fiona-1.8.18.tar.gz (1.3 MB)
|████████████████████████████████| 1.3 MB 4.8 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python#3.9/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-fbu0u179/fiona/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-fbu0u179/fiona/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/tmp/pip-pip-egg-info-knmlby9t
cwd: /private/tmp/pip-install-fbu0u179/fiona/
Complete output (2 lines):
Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config'
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

GDAL is a required library for Geopandas and it needs to be built and compiled on your system and in your path before you pip install geopandas
If you are using homebrew, you can install it with
brew install gdal
and verify the installation by running
gdal-config --version
One note is that Gdal has a lot of dependencies and will take a bit to install. Using homebrew, it worked for me in one shot but it will likely upgrade a number of prerequisites including GCC and perhaps even python itself.
I should note that this worked for me on Catalina. If you are an M1 Mac with Big Sur every tool in this chain may not be upgradeable to native M1 code at this time and you may need some of the workarounds at How to run the Homebrew installer under Rosetta 2 on M1 Macbook

Related

Can't install docopt module in a virtual env

I am trying to install docopt module in a virtual env, which is failing, but able to install urllib3 module.
I am creating virtual env as a unprivileged user
$ python3 -m venv yogi-venv
$ source yogi-venv/bin/activate
$ pip3 install urllib3
Collecting urllib3
Using cached https://files.pythonhosted.org/packages/5f/64/43575537846896abac0b15c3e5ac678d787a4021e906703f1766bfb8ea11/urllib3-1.26.6-py2.py3-none-any.whl
Installing collected packages: urllib3
Successfully installed urllib3-1.26.6
You are using pip version 10.0.1, however version 21.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/8a/d7/f505e91e2cdea53cfcf51f4ac478a8cd64fb0bc1042629cedde20d9a6a9b/pip-21.2.2-py3-none-any.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 15.2MB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-21.2.2
$ pip3 list
Package Version
---------- -------
pip 21.2.2
setuptools 39.0.1
urllib3 1.26.6
$ pip3 install docopt
Collecting docopt
Using cached docopt-0.6.2.tar.gz (25 kB)
ERROR: Command errored out with exit status 1:
command: /home/servicejenkins_build/yogi-venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-r1pocera/docopt_bf20fbd042814635ba33a7f102d490d3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-r1pocera/docopt_bf20fbd042814635ba33a7f102d490d3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-lk__1tg2
cwd: /tmp/pip-install-r1pocera/docopt_bf20fbd042814635ba33a7f102d490d3/
Complete output (7 lines):
running egg_info
creating /tmp/pip-pip-egg-info-lk__1tg2/docopt.egg-info
writing /tmp/pip-pip-egg-info-lk__1tg2/docopt.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-lk__1tg2/docopt.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-lk__1tg2/docopt.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-lk__1tg2/docopt.egg-info/SOURCES.txt'
error: [Errno 13] Permission denied: '/usr/local/lib/python3.7/lib2to3/Grammar3.7.0.final.0.pickle'
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz#sha256=49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491 (from https://pypi.org/simple/docopt/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached docopt-0.6.1.tar.gz (25 kB)
Any ideas where I am wrong?

google buildpack psycopg2-binary Error: pg_config executable not found

This is in my requirements.txt
psycopg2-binary==2.8.3 # via -r requirements/base.in
that I am building inside docker image. I was under impression that if I install psycopg2-binary vs psycopg2 I should not install additional postgresql devel libs. Am I wrong?
pack build --builder=gcr.io/buildpacks/builder:v1 test-python
Collecting psycopg2-binary==2.8.3
Downloading psycopg2-binary-2.8.3.tar.gz (378 kB)
ERROR: Command errored out with exit status 1:
command: /layers/google.python.runtime/python/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/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-vsc_2hlv
cwd: /tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/
Complete output (23 lines):
running egg_info
creating /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info
writing /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.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
<http://initd.org/psycopg/docs/install.html>).
No, you are not wrong; I had the same issue today, and after a bit of googling I found this (solved) github issue: https://github.com/psycopg/psycopg2/issues/699#
The comments there (https://github.com/psycopg/psycopg2/issues/699#issuecomment-377188700) indicate one possible cause for the issue is using an outdated version of pip.
I was using version 18.x, and after upgrading it (python -m pip install -U pip, which got me pip 21.1.3), the installation of psycopg2-binary finished successfully (as expected) even though I don't have any postgres dev libraries installed.

how to install matplotlib with pip

How can I install matplotlib with pip. I have try to use pip install or install from source
I have python 3.9 beta version btw
git clone git#github.com:matplotlib/matplotlib.git
cd matplotlib
python -mpip install .
but I get the following error
$pip install matplotlib
Collecting matplotlib
Using cached matplotlib-3.3.2.tar.gz (37.9 MB)
ERROR: Command errored out with exit status 1:
command: /Users/a/.pyenv/versions/3.9.0b5/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/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/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-pip-egg-info-ny9shc_k
cwd: /private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/
Complete output (63 lines):
WARNING: The wheel package is not available.
Edit setup.cfg to change the build options; suppress output with --quiet.
BUILDING MATPLOTLIB
matplotlib: yes [3.3.2]
python: yes [3.9.0b5 (default, Oct 2 2020, 00:38:55) [Clang 11.0.3
(clang-1103.0.32.29)]]
platform: yes [darwin]
sample_data: yes [installing]
tests: no [skipping due to configuration]
macosx: yes [installing]
running egg_info
...
File "/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/setupext.py", line 469, in add_numpy_flags
import numpy as np
File "/private/var/folders/k0/3v16x2k52tdf00j6tpm7wffc0000gp/T/pip-install-vq_esy_g/matplotlib/.eggs/numpy-1.19.2-py3.9-macosx-10.15-x86_64.egg/numpy/__init__.py", line 286, in <module>
raise RuntimeError(msg)
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Since your python version is 3.9 you can install matplotlib with pip3
pip3 install matplotlib
You can also try
python3 -m pip3 install -U matplotlib
Edit
You may not have installed the setup tools correctly, try :
pip install --upgrade setuptools
and then pip install matplotlib

installing openbabel3 with pip

I tried pip install openbabel --log log_file and I got 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: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/59/zn1rl7b13tqc7t2njskzp6th0000gn/T/pip-install-d2aqd_xf/openbabel/setup.py'"'"'; __file__='"'"'/private/var/folders/59/zn1rl7b13tqc7t2njskzp6th0000gn/T/pip-install-d2aqd_xf/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 /private/var/folders/59/zn1rl7b13tqc7t2njskzp6th0000gn/T/pip-record-i_0qytcj/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7m/openbabel Check the logs for full command output.
Here pip is an alias for pip3.
The log file is here (I am not sure if you can read it, this is my first time sharing a file)
note: A few days ago I opened a second user on my computer, I don't know how it affects things but maybe that's the reason.
I am using Mac OS Catalina.
From a quick look at the log file it looks like it wont install as it cant find a version for Mac OS, only for Windows, however the following may be useful as a workaround to that: How to Install openbabel for Python 3.6 on macOS Sierra 10.12.3
So I found a much simpler way than building openbabel manually. brew install openbabel works for openbabel3
Check the link: http://openbabel.org/wiki/Category:Installation

Pyttsx3 is not installing on Windows

I have python 3.7.6 installed and when I try to install pyttsx3 on my windows 10, I had an error, that I need mac os, but it installing on another computer with windows. I have tried to reinstall python and cleared pip cache, but it didn't work.
This is an error:
ERROR: Command errored out with exit status 1:
command: 'c:\users\pfkcs\appdata\local\programs\python\python37-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\pfkcs\AppData\Local\Temp\pip-install-y_mkf7t4\pyobjc-core\setup.py'"'"'; file='"'"'C:\Users\pfkcs\AppData\Local\Temp\pip-install-y_mkf7t4\pyobjc-core\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 pip-egg-info
cwd: C:\Users\pfkcs\AppData\Local\Temp\pip-install-y_mkf7t4\pyobjc-core\
Complete output (2 lines):
running egg_info
error: PyObjC requires macOS to build
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
try pip install -U pyttsx3
If still not working, you may have to install a specific version of pyttsx3. The most stable previous version is 2.71, you can install it by pip install -U pyttsx3==2.71
Hope this works.
It might help to run your Python code in an virtual env, by either anaconda if you have it installed: conda create -n <venv name> python=3.6 or python -m venv . if you do not have anaconda. Then either pip install pyttsx3 or py -m pip install pyttsx3 if the other doesn't work
First you have to install Python for windows extension. click here to download
Then you’ll need to give your virtualenv access to the system site-packages in order to install pyttsx.:
virtualenv --system-site-packages myproj
. myproj/bin/activate
pip install pyttsx
may be this could help you

Resources