Pip install --global-option="-L/<library path>": option -L not recongnised - python

I am trying to install cartopy on a Windows machine, and have previously installed QGIS and GEOS through OSGeo4W64. Now, when I try installing cartopy, I get the following error:
fatal error: 'geos_c.h' file not found
As mentioned, GEOS does exist and the file is also to be found within the directory. I the tried giving Pip the absolute path to the library as a global option, as follows:
pip install --global-option="-Lc:\OSGeo4W64\include"
This, unfortunately didn't work because Pip didn't recognise the -L library option:
error: option -L not recognized.
I tried -I, -l, and -i as well, just to see what would happen, but I get the same error every time. I also found examples on how to give paths to global-option and they did use -L and -I without problems. What could I be doing wrong?
Any help would be greatly appreciated.

It depends where you get your GEOS from as to which GEOS header file you should be linking against. If you get it from Christoph Gohlke's excellent binaries, or conda-forge, enthought, or Anaconda, I believe all rename geos_c.h to geos.h. If you get it from other sources, it may be that that renaming doesn't take place.
You can see how conda-forge build cartopy on Windows at https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/. The two important files:
https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/bld.bat
https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/cartopy.win.patch
Notice how that latter patch file renames the header dependency to geos.h, rather than geos_c.h because it is using the GEOS packaged by conda-forge. You may need to do a similar thing in your situation.
A history on this subject can also be found at https://github.com/SciTools/conda-recipes-scitools/issues/29#issuecomment-66497972.

Related

Package seems not to be well installed (file not found)

I am using lazypredict to try to find good algorithms (source: here). The command pip install yields no error, and I have also done the upgrade of the package, yet when I use from lazypredict.Supervised import LazyRegressor (which should work according to the documentation) I end up with the following error:
OSError: dlopen(/Users/gaetanlefloch/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
Referenced from: /Users/gaetanlefloch/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so
Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
Did someone have the same issue (with lazypredict or another package), and how can I overcome it without eventually doing a manual installation ?
Based on the presence of a /Users/... path in the logs you shared, I'm assuming you are on macOS.
LightGBM requires OpenMP by default, and links to it dynamically. That means that it expects to find it installed on your system at runtime.
Use Homebrew (link) to install OpenMP.
brew install libomp
If you are using lightgbm < 4.0 and Homebrew gives you libomp>=15.0, you may need to help Python find that library.
You can do that modifying environment variable LD_LIBRARY_PATH.
export LD_LIBRARY_PATH=/usr/local/opt/libomp/lib:"${LD_LIBRARY_PATH}"
Or by using brew link.
brew link --force libomp

MKL Issues installing PyFlashlight

I am attempting to install from a Python setup. I had this working after a month of hell-ish attempts on 18.04, and now need it on 20.04.
The setup.py while I am using is on this repository ( https://github.com/flashlight/flashlight/tree/main/bindings/python ).
I am using Ubuntu 20.04, fresh install sans a few dependencies I know the system needs.
I have Python3.10 installed locally.
During the install at steps
cd bindings/python
python3.10 setup.py install
I hit the error
CMake Error at cmake/FindMKL.cmake:400. MKL library not found. Please specify the library location by appending the root directory of the MKL installation to the environment variable CMAKE_PREFIX_PATH
Which is weird for a variety of reasons.
I did a sudo apt-get install mkl-devel which took, but also
The setup script claims it defaults to MKL off.
Right prior to this error, I do get a warning.
Cmake Warning at cmake/FindMKL.cmake:387. MKL libraries files are found, but MKL header files are not. You can get them by 'pip install mkl-devel' (I did this btw) if using pip. If build fails with header files available on the system, please make sure that CMake will search the directory containing them by setting CMAKE_INCLUDE_PATH
That last part I did not do, primarily because I'm not sure how to tell where pip install mkl-devel would have put those header files.
That said, when I do a find / "*mkl*" I notice files in two primary locations
.h files : /home/myusername/.local/include
.so files: /home/myusername/.local/lib
So I set the following environment variables in my terminal
LIBRARY_PATH=/home/myusername/.local/lib
LD_LIBRARY_PATH=/home/myusername/.local/lib
KENLM_ROOT=/home/myusername/Flashlight/kenlm
USE_MKL=0
CMAKE_INCLUDE_PATH=/home/myusername/.local/include/
CMAKE_PREFIX_PATH=/home/myusername/.local/lib
However when I try to install again, the process still fails with both of the MKL issues above (Warning and Error)
I'm baffled at what I am supposed to be pointing where to get this to succeed at this point.

Installing multiple python packages that requires different LDFLAGS/CPPFLAGS (macOS Big Sur Apple Silicone)

When installing python requirements from requirements.txt file, there were several packages that required different values in LDFLAGS/CPPFLAGS.
first, I got this when installing mysql-client:
ld: library not found for -lzstd
I solved it by running the pip install like this:
CPPFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" pip install mysqlclient
than, I had this issue when installing cryptography:
build/temp.macosx-10.14-arm64-3.8/_openssl.c:575:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
Solved it by installing it like this:
CPPFLAGS="-I/opt/homebrew/opt/openssl#1.1/include" LDFLAGS="-L/opt/homebrew/opt/openssl#1.1/lib" pip install cryptography
My question is - what is going on here? I want to keep LDFLAGS/CPPFLAGS values in my .zshrc but seems that for every package I need diferent values there??
When working on my old mac I remember that the values were
export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"
which are the values that are suggested to you by brew after you brew install mysql-client.
As long as they do not conflict with each other, you can put multiple directories in there with something like
LDFLAGS='-L/opt/foo/lib -L/usr/local/bar/lib'
and ditto for CPPFLAGS.
However, personally I'd avoid putting LDFLAGS and CPPFLAGS in .zshrc — as you have found out, the required values often depend on the thing you are compiling, and setting them globally (and then inevitably forgetting about them) is likely to cause confusion at some point in the future.

Anaconda "import georaster" error: specified module not found

I am using Anaconda3 5.2.0 for Windows 10 64 bit, which is python 3.6.5 (Anaconda3-5.2.0-Windows-x86_64.exe). I have installed this into C:\Anaconda3 and then from the anaconda prompt installed basemap:
conda install -c conda-forge basemap
conda install -c conda-forge basemap-data-files
I have used this to start building map files and everything is working fine. I then wanted to add a raster to the map using georaster.
conda install -c conda-forge georaster
This also installs gdal.
When I open Jupyter Notebook and enter the line
import georaster
I get the following error message:
ImportError: DLL load failed: The specified module could not be found.
I have tried various solutions that I have seen for related issues including installing a gdal update, fiona, and geopandas. None of these change the message.
I tried installing gdal using the binaries .whl file in conda, but despite following the advice (which said to use pip) I was not able to make it work.
pip install GDAL-2.2.4-cp37-cp37m-win_amd64.whl
resulted in an error message:
GDAL-2.2.4-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Finally I went looking to see if I could locate the missing DLL manually. I saw one user suggest libtiff.dll was the missing file, and indeed it was one I did not have. I downloaded it and copied it into the System32 and SysWOW64 folders. This still resulted in an error but changed the error message:
ImportError: DLL load failed: %1 is not a valid Win32 application.
However I could not find a way to stop the error from occurring. I followed the steps to register the .dll but that also had an error message from not found to not supported:
(cmd prompt in administrator mode)
regsvr32.exe /i libtiff.dll
The module "libtiff.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The specified module could not be found.
I have tried downloading from 2 other websites, neither with any success. It is feeling like every method I attempt now just hits some weird error that nobody else is seeming to have and I don't understand why.
If anyone could offer some advice I'd be very appreciative. Thank you in advance.
downloading the required *.whl file(GDAL-2.2.4-cp36-cp36m-win_amd64.whl) from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and then copying it to a location like C:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
then pip install c:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
worked for me.
Thanks.

Problems with Installing Python Packages

I've seen some past threads that discuss similar problems, but none seem to be having exactly the problem that I am having. I was having problems with installing packages with Python, even though I'd managed to install them before. When I attempted to run gcc, it seemed to not be installed, so I uninstalled Xcode completely and just installed the command line tools (I really only use the command line tools, and could use the extra disk space).
Though the installer said that the installation was successful, gcc results in the following error:
xcrun: Error: could not stat active Xcode path '/Applications/Xcode.app/Contents/Developer'. (No such file or directory)
I have tried to redirect the path by using the following command:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
It doesn't seem to work, though.
I've also tried using the following command:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
but it returns the following error: xcode-select: Error: Path "/Applications/Xcode.app/Contents/Developer" is not a directory.
Which makes sense I think -- after all, I did uninstall Xcode, so I suppose I should point it to the Command Line tools directory? I'm not sure how to do this, though.
I'm using Mac OS X 10.8.5, by the way.

Categories