MKL Issues installing PyFlashlight - python

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.

Related

Found Python3.9, but I want to use python3.10

Due to some breakage in another project that didn't run in python3.10 I had to install python 3.9 on my ubuntu 22.04 machine. Because python3.9 is not available in the package repositories, I cloned the github repository and ran configure, make and make install, which installed python3.9 into /usr/local/bin.
Now I am trying to compile pivy against python3.10, which is my default python version. But I think CMake picks up python3.9 now by default. I tried reinstalling python with sudo apt install python3 --reinstall, but that didn't help. I also tried to replace all occurrences of python3.9 with python3.10 in the files generated by cmake, but that also gave an output of -- Found Python: /usr/local/bin/python3.9 (found version "3.9.13") found components: Interpreter Development Development.Module Development.Embed on the first line of make.
I have found a similar question, but it doesn't exactly match what I want. Firstly, I don't know what the installation directory for the apt python version is. the python binary is in /usr/bin/, but so could be the 3.9 version (it's in /usr/local/bin/ right now). Secondly, I would like to have that as the default.
I have tried removing the softlink to python3.9-config in /usr/local/bin/python3-config
and running python3-config now runs the one in /usr/bin/python3-config, which points to the 3.10 version. However running cmake now says it can't find python at all. Even after clearing the cmake cache and reseting the repository.
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Python (missing: Python_EXECUTABLE Python_INCLUDE_DIRS
Python_LIBRARIES Interpreter Development Development.Module
Development.Embed)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22/Modules/FindPython.cmake:561 (find_package_handle_standard_args)
CMakeLists.txt:17 (find_package)
I have tried creating a new softlink to the correct python3-config in /usr/local/bin, but that gave the same cmake error.
apt-file search FindPython revealed that that file is in the cmake-data package, which I reinstalled. That also didn't work.
I don't know what to do now. How can I make cmake find the correct python version by default? There are no entries for python or python3 in update-alternatives. I noticed there are a lot more python executables in /usr/local/bin/, for example python-argcomplete-tcsh, is that a problem if I want to use 3.10 by default?
I was able to get around the issue for now using
cmake .. -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=/usr/bin/python3.10 -DPython_INCLUDE_DIRS=/usr/include/python3.10/
But that's only a stopgap measure. I would like a proper solution that makes FindPython work properly again.

Cannot install Python projects in readthedocs

I've got a couple of projects here for which I'm preparing documentation at the moment, hosted at readthedocs.org. FYI, all of them use poetry and I use custom .readthedocs.yml files with this entry:
python:
install:
- method: pip
path: .
It works fine for most projects, but it fails for two for different reasons during installation of the project via pip:
The first one uses PyGObject, which failes like this:
Package gobject-introspection-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-introspection-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gobject-introspection-1.0' found
Command '('pkg-config', '--print-errors', '--exists', 'gobject-introspection-1.0 >= 1.56.0')' returned non-zero exit status 1.
Try installing it with: 'sudo apt install libgirepository1.0-dev'
So it seems that PyGObject cannot be installed without some system packages to be installed. I could rearrange the code so that the import is not top-level. But still I need it in the dependencies. Can I tell pip install to ignore this single package somehow? Any other idea?
The second project compiles some C++ code via Cython and fails, because it's missing a library. I use a custom build script in the pyproject.toml:
[tool.poetry.build]
script = "build.py"
generate-setup-file = false
Is there some flag in pip that I could set and retrieve in build.py to skip the compilation? Or is there a better way?

Where did my python module install to?

I'm running python 3.6 via anaconda 3, using Visual Studio Code.
I followed instructions like these (Interactive Brokers API install) and downloaded the package to a local directory of mine say: c:\dev\pyib, so now the code is in c:\dev\pyib\IbPy-master
I open that directory in command line and run
python setup.py install
All runs ok.
But then my program, which is in c:\dev\pyib says Module not found. (In my case ibapi). The linter is also showing red.
There is no other python installed on this pc.
Where did the package install to? and how do I check that? What will I find where the package installed itself to that shows me its there?
Or do I have to use a trial-and-error with the linter and sys.path.append()? (I tried that with the directory where the files are downloaded to - to no avail)
I'm trying to set up the PYTHONPATH using the "env" in launch.json from Visual Studio Code, as shown in this unaccepted answer.
Current sys.path:
'c:\\dev\\pyIb',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\python36.zip',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-
packages',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Babel-2.5.0-py3.6.egg',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin'
I deleted the ib directory and re-ran the install. The last line says: Writing C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-pac‌​kages\IbPy2-0.8.0-py‌​3.6.egg-info So is the location of the egg-info the location of my undetected module? The actual folder in the site-packages is called ib.
Or could my problems be because of a difference in Lib vs. lib with the lowercase in the sys.path and the uppercase in the actual directory?
But the real question here is still: HOW DO I KNOW WHERE the package was installed what should I search for?
This answer is specific for anaconda3 Python and packages installed using python setup.py install (which is actually using distutils)
Take a look at anaconda3\Lib\site-packages you should see a directory for the package you installed.
The way to know for sure where your package is, is by doing a pip list then trying to pip uninstall and re-install again using the python setup.py install: Here are the detailed instructions:
When uninstalling, pip will tell you it cannot because it was done via distutils.
You'll get a message like this:
DEPRECATION: Uninstalling a distutils installed project (ibpy2) has been deprecated and will be removed in a future version.
This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
You'll be prompted to continue anyway. If you choose No, then you can find the directory in
C:\Users\<yourusername>\AppData\Local\Continuum\anaconda3\Lib\site-packages
Thanks to Emanuel Mtali for pointing me in the right direction
Some more information:
The problem I had was due to a stupid mistake of mine. I was running setup of a different (but related) package not used anymore. IbPy2 instead of TwsAPI. I was supposed to run the setup.py of the package installed via the latest version of the MSI from IB, and NOT the IbPy2 package. :-(

Gohlke's numpy + mkl installation - Change MKL install directory on Windows

I've been trying to get a working fast numpy with BLAS on Windows, and so far, the only method that seems feasible is downloading the precompiled library with MKL from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy.
So far ok, but chekcing later numpy.__config__.show(), I see it points to directories that don't exist, such as C:\program files (x86)\IntelSWTools
I assume numpy is trying to place the MKL libraries in this directory, but I have no administration privileges for creating files in C:\program files (x86).
Is there any simple way to use this numpy distribution and install the MKL libs in another directory? Such as a pip install filename.whl --some_option_to_install_mkl_in_another_dir?
(Windows 7 64bit, python 3.5.2)
Already attempted:
Use pip install <package> --user: it seems to install everything exactly the same way as the same command without --user. (My default installation folder is aldready the user folder)
User pip install <package> --root <some_path>: installs everything in the passed path, but Numpy config still points to C:\program files (x86)\IntelSWTools, and python cannot find numpy, even if I add <some_path> to both PATH and PYTHONPATH environment vars
Tried to create the pip.ini file, with the lines [global] and target=E:\destination. The destination folder remains untouched.
Rename the wheels file to zip, find all files containing the IntelSWTools folder, change all these folders to one that I have access to. Make it a wheels file again and pip install. Absolutely no file appears in the folder I chose, but numpy config is pointing to that folder. -- This makes me wonder: does this distribution really installs MKL?
Numpy+MKL does not place (or try to place) MKL libraries in C:\program files (x86)\IntelSWTools. The MKL runtime DLLs necessary to use numpy+MKL are copied to sys.prefix\Lib\site-packages\numpy\core during installation with pip.
C:\program files (x86)\IntelSWTools is the location of the MKL development files (link libraries, header files, DLLs, documentation) that were used to build numpy+MKL. If you want to build other software from source that relies on MKL development files, you need to download MKL from Intel.
I have tried something like this:
pip install --install-option="--prefix=$PREFIX_PATH" package_name
I the above line:
$PREFIX_PATH ---- Change the path you want to specify.
package_name ---- Change the Package name with the desired package name or the wheel file.
On Windows, I tried the above and it is not working. But the below answer will work:
python.exe -m pip install --target=c:\data\ pandas
The pandas got stored in the data folder. Only the thing we need to do is we have to specify the path to our Python, so that it will fetch the proper library. You can go in the data folder and run python. You will be able to access the library.
Hope this helps you.

pystan: CompileError: command 'gcc' failed with exit status 1 (Windows)

Before I get to far into this, I should note that I have seen a very similar question, but the solution presented did not work for me. Perhaps one reason why is because that was Linux build and my current difficulty is on a Windows 7 machine. I use Cygwin to get access to the gcc (5.2.0) compiler suite.
In any event, I have been attempting to try out Stan via PyStan. I am working with an Anaconda (2.4.1 64-bit) distribution which I just updated today (Python 2.7.11). I initially tried to install PyStan via pip, but the install keeps failing due to what looks like the following error:
Cannot build msvcr library: "msvcr90d.dll" not found
Consequently, I used conda instead, which seemed to install just fine. (I should note that the conda install pushed my numpy back to an earlier version, which created conflicts with the pandas upon import. I just updated anaconda to deal with these broken dependencies.) I was also able to import PyStan without any problems. However, when I actually tried to fit a model (inside of a Jupyter Notebook), the process failed with the exception in the title.
The first thing I did was confirm that gcc was where in the referenced location (not shown in the title). Indeed it was, and it seemed to working just fine. I then tried to run the model as a script from the command line (still using Python), and it failed with the same error. When I recreated the model via the REPL, it pointed to a different location that had a .bat file referencing the (verified) compiler, and that failed as well.
I am pretty sure this is because I have Visual Studio 2012, instead of Visual Studio 2008. While it is possible for me to run parallel installations, if this code is going to be useful for others in the future, these are not reasonable hoops to jump through to make it happen. I was hoping that someone else might have a better explanation. Any info would be greatly appreciated.
Beneficial from the post at https://github.com/stan-dev/pystan/issues/306
I have met various error message, but finally, I install PyStan successfully.
My machine is also on Windows 7, x64 with Anaconda3 installed.Here are the procedures to install PyStan from the sourced codes.
Install Visual Studio 2017 & Visual Studio C++ Build Tool 2015 at http://landinghub.visualstudio.com/visual-cpp-build-tools
Update Conda
conda update conda
conda update --all
check the dependencies
pip install setuptool
conda install numpy cython matplotlib scipy pandas
Install gcc compiler components
conda install libpython
conda install -c msys2 m2w64-toolchain=5.3.0
created distutils.cfg file inside Anaconda3\Lib\distutils folder with the following:
[build]
compiler = mingw32
Download Git at https://git-scm.com/downloads
git clone --recursive https://github.com/stan-dev/pystan.git
Compile from the source code
python setup.py build --compiler=mingw32
python setup.py install
P.S. The solution for the issue: Cannot build msvcr library: "vcruntime140d.dll" not found.
Copy vcruntime140d.dll from C:\Windows\System32 to any folder, which is reachable in the path in the advanced system settings/environment variables/ system variables.

Categories