ImportError blpapi in Python - python

I'm trying to use blpapi in python. Since my company has a strict firewall, I had to do an offline install of the latest one from condaforge ('blpapi-3.17.1-py38_blpapicpp3.16.1.1_1'). I've tried nearly every solution on stackoverflow including:
Pasted the matching C++ SDK dll libraries for C++ 3.17.1.1 into the DAPI folder and anaconda site packages.
Also pasted the dll files in system32 and tried running import blapi with os.add_dll_directory function.
Added the bin and lib C++ SDK dll paths to the system environment PATH as well as in Spyder.
Installed Visual Studio and the relevant C++ MFC, C++/CLI support, MSVC v143 tools etc.
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-10-10.0.19041-SP0
Architecture: ('64bit', 'WindowsPE')
Python: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
Python implementation: CPython
This Python version does not use PATH to find dlls
blpapi package at: "C:\ProgramData\Anaconda3\lib\site-packages"
Current directory: "C:\blp\blpapi_cpp_3.17.1.1\lib"
----------------------------------------------------------------------
DLL load failed while importing _versionhelper: The specified module could not be found.
Could not open the C++ SDK library.
Download and install the latest C++ SDK from:
http://www.bloomberg.com/professional/api-library
If the C++ SDK is already installed, Python 3.8+ on Windows requires that the
path to the library is added to 'add_dll_directory', i.e.:
with os.add_dll_directory('<path to blpapi dlls>'):
import blpapi```

Related

Cython setup.py can't find installed Visual C++ Build Tools

I am attempting to build my cython code using this setup.py file:
from distutils.core import setup
from Cython.Build import cythonize
import numpy as np
setup(
name="My Cython Project",
ext_modules=cythonize("*.pyx", include_path=[np.get_include()], language="c++")
)
and
python setup.py build_ext --inplace
But am getting the error:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
But I installed the build tools and I know they work because I can manually build my project using these commands in the Developer Command Prompt for VS 2019:
cython -a -3 --cplus Myfile.pyx
cl /LD /O2 /EHsc [ include files ] Myfile.cpp [ python 3.8 lib ]
Why does cython think the build tools are not installed? Do I need to add something to PATH?
(I run the same project on my macOS machine with gcc installed and it works perfectly.)
Screenshot of my Visual Studio Installer Screen
The problem is that setup.py shows you incorrect version of MSVC. It's not the 14.0 that you need. I just did solved the very same issue myself, also for Python 3.8, so here are the steps.
When you compile something for Python, you should use the same compiler version. So let's see what compiler was used for you Python:
python -c "import sys; print(sys.version)"
Mine prints:
3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
So I need MSVC version 1916.
You can check which version it is here: https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B . For me 1916 is Visual Studio 2017 version 15.9 - likely that's what you really need.
You to M$ downloads https://my.visualstudio.com/Downloads?q=Visual%20Studio%202015&pgroup= , search, for example, for "Visual Studio Community 2017 (version 15.9)" and install it (or just the compiler) and enjoy.
P.S. It is likely that you will need exactly that compiler for all your python 3.8 extensions (unless you use direct dll calls) and you will need to recompile the code you did in Studio 2019.

I am getting Import Error in python 3.8.3

I was getting this Error while importing Tensorflow 2.0 in python 3.8.3
ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

Facing ImportError: DLL load failed while implementing Microsoft azure iothub_service_client

I am trying to develop a python console application that implement IoT using Microsoft azure. For this purpose, I am following very basic tutorial made for python developers by Microsoft azure in my Windows 10 machine. Pre-installed Visual C++ redistributable package is one of the most important requirement to allow the use of native DLLs from Python among 4 prerequisites described into the Introduction section of the tutorial.
My system configurations:
Software Version
-------------------------------------------------------
Python: 3.5.2
Visual C++ redistributable package: 2010, 2013, 2017
Node: 6.10.2
Figure of Visual C++ redistributable package:
Problems:
Visual C++ redistributable package is not installed since Visual C++ redistributable package in the tutorial is an older version (2015) then mine (2017).
It shows following error:
Traceback (most recent call last):
File "CreateDeviceIdentity.py", line 2, in <module>
import iothub_service_client
File "F:\Settings\Windows\ProgramFiles\Python\lib\site-packages\iothub_service_client\__init__.py", line 1, in <module>
from .iothub_service_client import *
ImportError: DLL load failed: The specified module could not be found.
Question:
How how can I solve this problem?
N.B: I have completed those basic tutorial provided for Java and NodeJS developers.
I tried to reproduce your issue successfully, and I made the code import iothub_service_client works after installed Visual C++ Redistributable for Visual Studio 2015. So please install the 2015 version on your machine to resolve it, as the tutorial said,
If you are using Windows OS, then Visual C++ redistributable package to allow the use of native DLLs from Python.
The link in the tutorial is for the 2015 verison.

pythran - File format not recognized and Unknown MS Compiler version 1800

I am new to pythran and right now encountering the problem of File format not recognized as follow:
D:\DevWorkSpace\cython>pythran dprod.py
WARNING Pythran support disabled for module: omp
Looking for python27.dll
objdump.exe: D:\Program Files\Anaconda2\python27.dll: File format not recognized
CRITICAL Chair to keyboard interface error
E: Symbol table not found
Mine OS is Win 10 64bit. The version of Pythran is 0.7.4.post1. The python I use is anaconda 2:
Python 2.7.11 |Anaconda 2.3.0 (64-bit)| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
Because I first tried Cython, I installed Visual Studio 2008 SP1 and Windows SKD for VC 2008 first. Then I installed MinGW for the gcc complier(gcc version 4.93) and follow this answer to use gcc compiler. This was the first time I got this problem File format not recognized.
Then I uninstall pythran and reinstall it again using:
pip install --global-option build_ext --global-option --compiler=mingw32 pythran
and I got this: failed to create process.
I also tried to install pythran from source code from pypi and installed it using:
python setup.py install. It didn't work.
In addition, I can't install pythran from conda, which gave me the following message:
C:\Users\JHW>conda install -c serge-sans-paille pythran
Fetching package metadata: ......
Solving package specifications: .
Error: Package missing in current win-64 channels:
- pythran
Did you mean one of these?
python, ipython
You can search for this package on anaconda.org with
anaconda search -t conda pythran
Finally, I also tried to replace it with another python27.dll, which is copied from \MySQL\MySQL Workbench 6.3 CE. This File format not recognized disappeared, but still pythran didn't work. By "pythran didn't work", I mean
D:\DevWorkSpace\cython>pythran dprod.py
WARNING Pythran support disabled for module: omp
CRITICAL Chair to keyboard interface error
E: Unknown MS Compiler version 1800
Thanks to #cdarke's comment, it seems that I should turn to the issue of compiler though. I have to admit that I omit this error when I posted this question. The reason I left out this question is that when I replaced the python27.dll in anaconda2, the iPython notebook in anaconda can't work (when I started it, a window of cmd pops out and disappears too soon for me to catch errors)
So my questions are:
where to find the suitable python27.dll to solve the File format not recognized problem without damaging the iPython notebook function. (or how to keep the errors at start of iPython notebook)
hints to solve the Unkown MS Compiler version 1800. (I am trying to figure out how to solve the compiler problem right now, but I am new to MS compiler. So any hints would be greatly appreciated!)
Thank you very much in advance!
According to the documentation, Pythran only supports Windows through WinPython.
The reason behind this choice is the lack of good support for all C++11 features support in Visual Studio C++ Compiler…

How to change Python default compiler to GCC?

I have Windows 10 and Python 2.7 installed. When I run IDLE I find this:
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[MSC v.1500 32 bit (Intel)]
I want the default compiler here to be MinGW's GCC (I already installed MinGW) becaue I cannot import Theano with the MSC compiler
I tried all the tutorials out there and every time I successfully install Theano but when I try to import it I get the error "Problem occurred during compilation with the command line below:" and I get a huge list of errors. Btw, I don't have VS installed on my system
Edit Distutils config file C:\Python2.7\Lib\distutils\distutils.cfg (Create the file if it already does not exist).
Add the following to the file:
[build]
compiler = mingw32
This should work.

Categories

Resources