Package installation failed - psycopg2 in OsX - python-3.x

I tried install the postgresSQL adapter for the Python:
$ pipenv install psycopg2
And I got this error:
Installing dependencies from Pipfile.lock (45527d)…
An error occurred while installing psycopg2==2.8.2...
The error stack is soo long, here the last lines:
(...)bin/../include/site/python3.7/psycopg2" failed with error code 1 in /private/var/folders/wq/wp6z48kj7_z3ynpkchsmqjp80000gn/T/pip-install-8ffakjrp/psycopg2/']
Any tip about?

Use this:
pipenv clean
pipenv install psycopg2-binary

I had solved installing just the binaries an others libs. Here is:
$ brew install libxml2 libxmlsec1 pkg-config
$ pipenv install psycopg2-binary

I tried a bunch of stuff but I think this worked better.
$ xcode-select --install
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"

Related

poetry returns 'dyld: Library not loaded ... image not found' following brew install while inside virtual environment

I ran brew install postgresql while inside a poetry environment. Since then, I can't interact with poetry.
λ ~/ poetry
dyld: Library not loaded: /usr/local/Cellar/python#3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/Python
Referenced from: /Users/<my username>/Library/Application Support/pypoetry/venv/bin/python
Reason: image not found
[1] 5634 abort poetry
I get the same output when I try poetry <any other command>. I tried removing my virtual environments from λ ~/Library/Caches/pypoetry/virtualenvs/ expecting to be able to reinstall them from the .toml files in my projects, but can't run poetry install because I receive the same error.
I am running MacOS 10.15.7, Homebrew 3.3.12, poetry 1.1.12, & pyenv 2.2.4.
ECHO $PATH
/Users/<my username>/.poetry/bin:~/.local/bin:/Users/<my username>/Library/Python/3.9/bin:/shims:/Users/<my username>/.datacoral/cli/bin:/Users/<my username>/.nvm/versions/node/v12.13.0/bin:/Users/<my username>/bin:/usr/local/bin:/Users/<my username>/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/<my username>/.local/bin:/Users/<my username>/.local/bin
I faced this issue because when I executed brew install, brew updated the patch version of Python from 3.9.13_1 to 3.9.14.
This can be easily resolved by running the following to uninstall and then install poetry.
curl -sSL https://install.python-poetry.org | python3 - --uninstall
curl -sSL https://install.python-poetry.org | python3 -
I'm resolving this in case someone runs into the same issue.
Uninstalling and reinstalling poetry fixed the problem. I wasn't able to do this with the --uninstall option and instead had to do it manually. I first ran rm -rf pypoetry inside ~/Library/Application Support/. Then I re-ran the install line from poetry's site: curl -sSL https://install.python-poetry.org | python3 -.
The cause of the issue was using poetry shell instead of just poetry run jupyterlab –– this opened me up to absent-mindedly screwing up the poetry install by running brew installs while in the shell. Lesson learned!

Installing PyMuPDF on MacOS Big Sur

I wanted to import fitz in my code. To do that, I tried installing PyMuPDF using
pip3 install PyMuPDF
However, this installation fails and returns this error:
fitz/fitz_wrap.c:2754:10: fatal error: 'fitz.h' file not found
#include <fitz.h>
^~~~~~~~
1 error generated.
error: command '/opt/homebrew/clang' failed with exit code 1
I also tried installing mupdf and mupdf-tools via Homebrew. None of them could fix this issue.
I would appreciate any help to fix this installation error!
Assuming you are using M1 Mac, you can solve this problem installing mupdf, swig, freetype and latest version of PyMuPDF:
brew install mupdf swig freetype
pip install https://github.com/pymupdf/PyMuPDF/archive/master.tar.gz
Source: https://github.com/pymupdf/PyMuPDF/discussions/875
The instructions provided by Juan Garcia worked until June 18th 2022 for me. There's a few workarounds.
Solution #1
Install the wheel package using pip and swig + freetype using homebrew. PyMuPDF should build itself successfully when running pip install pymupdf. This takes about five minutes on a late model M1 MBP. This does not require the mupdf package installed via homebrew.
Solution #2
If you're using homebrew you can downgrade to 1.19.x with the following:
cd "$(brew --repo homebrew/core)" && git checkout 457cb59a52ff7666dc146c1c480d2ea98d63564f;
# If you already have mupdf installed use `brew reinstall` instead of `brew install`
cd "$(brew --repo homebrew/core)" && HOMEBREW_NO_AUTO_UPDATE=1 brew install mupdf;
cd "$(brew --repo homebrew/core)" && git checkout master && brew pin mupdf;
brew install swig freetype;
pip install https://github.com/pymupdf/PyMuPDF/archive/refs/tags/1.19.6.tar.gz;
For reference here is the Formula commit history: https://github.com/Homebrew/homebrew-core/commits/master/Formula/mupdf.rb

How to install python version 3.5.6 into ubuntu/ Linux?

I need to install python version 3.5.6. What are the requirements to install python 3.5.6.
python 3.6 is already installed on my local machine
What I have tried?
I looked into Python downloads. Downloaded tarball for python3.5.6.
Installed it by using following set of commands
wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz
tar -xf Python-3.5.6.tar.xz
cd Python-3.5.6
sudo apt-get install libbz2-dev libsqlite3-dev build-essential
./configure
make
sudo make install
After installation when I run python3 -V it shows python 3.6.
Expected behaviour
python3 -V command should show python3.5.6
What I am doing wrong?
Try uninstalling it or removing the package all together from your computer. Afterwards try:
$ sudo apt-get install --reinstall python3.5
or you could try:
$ sudo aptitude reinstall python2.7
Best of luck.
python3.5 might show 3.5.6, depending on where and how things are on your PATH.
Either way, instead of manually compiling and installing Python (especially as you're side-stepping your package manager (apt) here which may cause trouble down the line), look into pyenv. After installation, approximately:
$ pyenv install 3.5.6
$ pyenv local 3.5.6
$ python
and you're ready to roll.

How to fix Error 2 when trying to make haskell-platform?

I downloaded the Haskell-platform source from here: http://www.haskell.org/platform/linux.html, installed ghc, and did /.configure. However when I do sudo make, I get the following error:
Preprocessing library HUnit-1.2.4.2...
Test/HUnit/Base.hs:1:1:
Could not find module `Prelude'
Perhaps you haven't installed the profiling libraries for package `base'?
Use -v to see a list of the files searched for.
Error:
Building the HUnit-1.2.4.2 package failed
make: *** [build.stamp] Error 2
Does anyone knows how to fix this?
I'm trying to install on Ubuntu 12.04.1 LTS
Instead of trying to install from the sources, simply install the Ubuntu packages, which will be much simpler, with:
$ sudo apt-get install haskell-platform
If you need a local version of the documentation and the profiling libraries, install the additional packages with:
$ sudo apt-get install haskell-platform-doc haskell-platform-prof
Daniel Fisher's comment led me to the solution. You have to install all the profiling libraries for each of the ghc packages you have installed.
Just write
sudo apt-get install ghc*-prof
That's how it worked for me

Error: gdal-config not found while installing R dependent packages whereas gdal is installed

Please point out the point that I am missing:
openSUSE 11.3
xx#linux-y3pi:~/Desktop/R> sudo R CMD INSTALL rgdal_0.7-12.tar.gz
root's password:
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1353: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from http://www.gdal.org/
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config'
with appropriate values for your installation.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/usr/lib64/R/library/rgdal’
xx#linux-y3pi:~/Desktop/R> whereis gdal-config
gdal-config: /usr/local/bin/gdal-config
xx#linux-y3pi:~/Desktop/R> gdal-config
Usage: gdal-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--libs]
[--dep-libs]
[--cflags]
[--datadir]
[--version]
[--ogr-enabled]
[--formats]
xx#linux-y3pi:~/Desktop/R>
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
>
xx#linux-y3pi:~/Desktop/R> gdal-config --version
1.9.0
xx#linux-y3pi:~/Desktop/R> proj
Rel. 4.8.0, 6 March 2012
usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]
linux-y3pi:~ # $PATH
bash: /home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/home/xx/qtsdk-2010.05/qt/bin:/home/xx/qtsdk-2010.05/qt/bin/:/home/xx/qtsdk-2010.05/bin:/usr/lib64/mpi/gcc/openmpi/bin:/home/xx/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games: No such file or directory
In Ubuntu 18.04
I fixed this by sudo apt install libgdal-dev
Hope someone find this helpful. Some above answers seems to be outdated and lengthy.
In earlier versions (which had apt-get)
sudo apt-get install libgdal-dev
You need the -dev package with headers and shared library links for development besides the normal package for deployment. Two different use cases as far as the distro is concerned.
On my distribution:
edd#max:/tmp$ dpkg -l | grep gdal | cut -c-72
ii libgdal1-1.7.0 1.7.3-6ubuntu3
ii libgdal1-dev 1.7.3-6ubuntu3
edd#max:/tmp$
and R CMD INSTALL rgdal_0.7-8.tar.gz works just fine as you would expect from a CRAN package given all the build-time checks at CRAN.
Update late 2016: As #JoshO'Brien points out in the comment
Minor update: Here in 2016, running Ubuntu 14.04.2, libgdal1h seems to
have replaced libgdal1(though libgdal1-dev is still needed). At least
I get an error to that effect when I attempted to apt-get install libgdal1
For Ubuntu 16.04 the corresponding line would be
sudo apt-get install libgdal1i
Such renaming of upstream libraries is common; something such as apt-cache search libgdal can help locate the current package names. The important key though is that the "abstract" development package libgdal-dev is all that is needed to build as it pulls the "concrete" current run-time package (here: libgdal1i) in via a dependency.
You can use apt-file package, to find which package contains the missing file you are looking for.
First install the apt-file using the command apt-get install apt-file Update apt-file using the command apt-file update Now you can use apt-file to find the missing file. apt-file search gdal-config
For my case, I got the same error when configuring grass-7.1 from svn. As shown below:
$ ./configure
...more...
checking whether to use GDAL... yes
checking for gdal-config... /usr/bin/gdal-config
...more....
./configure: 1: ./configure: /usr/bin/gdal-config: not found
./configure: 6093: test: =: unexpected operator
configure: error: *** Unable to locate GDAL library.
But, after looking for gdal-config file with apt-file as shown below, I was able to resolve the error, after installing the package libgdal1-dev
$ apt-file search gdal-config
Results
libgdal1-dev: /usr/bin/gdal-config
So I installed libgdal1-dev, as shown below:
$ sudo apt-get install libgdal1-dev
This happens because the configuration failed for package ‘rgdal’
so we have to install necessary dependencies.
The packages libgdal-dev and libproj-dev are required:
sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev
Then install rgdal by
install.packages("rgdal")
Load rgdal by
library(rgdal)
On macOS
brew install gdal
removed the error
gdal-config not found
Try this on CentOS 6
sudo yum install gdal gdal-python gdal-devel mapserver mapserver-python libxml2 libxml2-python python-lxml python-pip python-devel gcc
Read the reference manual.
SystemRequirements for building from source: GDAL >= 1.6.0 library
from http://trac.osgeo.org/gdal/wiki/DownloadSource and PROJ.4 (proj
>= 4.4.9) from http://trac.osgeo.org/proj/;
The same problem occurred today to me on a Linux CentOS 6.10 on which I do not have administration rights.
What I did:
a) Create a conda environment dedicated to my R version
conda create --name MYR
b) Activate the environment
source activate MYR
c) Install R
conda install -c conda-forge r-base
d) Install libgdal
conda install -c conda-forge libgdal
This solved the problem for me. My R version was 4.1.3. I guess other versions should work.
For manjora or archlinux, just try:
yay -S gdal

Resources