I am trying to get set up with the Bloomberg Python API. I have been following along with this tutorial. I am able to successfully python -m pip install — index-url=https://bloomberg.bintray.com/pip/simple blpapi, but then when I try to run import blpapi in the Python interpreter, I get the following error. How do I resolve this error (wondering if it has something to due with me using Python 3.8)?
ImportError:
---------------------------- ENVIRONMENT -----------------------------
Platform: Windows-10-10.0.17763-SP0
Architecture: ('32bit', 'WindowsPE')
Python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]
Python implementation: CPython
blpapi 64-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_64.dll"
blpapi 32-bit will be loaded from: "C:\blp\API\blpapi_cpp_3.13.1.1\lib\blpapi3_32.dll"
System PATH: (* marks locations where blpapi was found)
"C:\Windows\system32"
"C:\Windows"
"C:\Windows\System32\Wbem"
"C:\Windows\System32\WindowsPowerShell\v1.0\"
"C:\Windows\System32\OpenSSH\"
"C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL"
"C:\Program Files\Intel\Intel(R) Management Engine Components\DAL"
"c:\nx_dll"
"C:\Program Files\nodejs\"
* "C:\blp\API\blpapi_cpp_3.13.1.1\lib"
"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\"
"C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\Scripts\"
"C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\"
"C:\Users\cpage\AppData\Local\Microsoft\WindowsApps"
* "C:\blp\DAPI"
"C:\blp\DAPI\DDE"
"C:\Users\cpage\AppData\Roaming\npm"
"C:\Program Files\Sublime Text 3"
"C:\Users\cpage\AppData\Local\hyper\app-3.0.2\resources\bin"
"C:\Users\cpage\AppData\Local\Programs\Microsoft VS Code\bin"
* "C:\blp\API\blpapi_cpp_3.13.1.1\lib"
blpapi package at: "C:\Users\cpage\AppData\Local\Programs\Python\Python38-32\lib\site-packages"
Current directory: "C:\Users\cpage"
----------------------------------------------------------------------
No module named '_versionhelper'
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, please ensure that the path to the library
was added to PATH before entering the interpreter.
You need to download the python blpapi package having the version matching your C++ lib.
In your case, since your C++ lib is 3.13.1.1, you can download the 3.13.1 python package:
pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.13.1
Just managed to make it run using version blpapi-3.15.2 using C++ API blpapi_cpp_3.15.0.1
To install run:
python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi
to import use:
import os
with os.add_dll_directory('<...>\blpapi_cpp_3.15.0.1\lib'):
import blpapi
or add '<...>\blpapi_cpp_3.15.0.1\lib' to PATH
The following procedure works out of the box for CPython 2.7 and 3.7. A Bloomberg rep claims he verified it for CPython 3.5 as well:
Download the C++ BLP API from the official Bloomberg repository. If this link breaks, use Bloomberg API Support homepage to find the up-to-date ones.
Unpack the archive to C:\Programs\blpapi_cpp_3.14.3.1
Exit from the shell.
Set the environment variable BLPAPI_ROOT=C:\Programs\blpapi_cpp_3.14.3.1\. Note that the trailing slash is important.
Start a new shell.
Execute python -m pip install --index-url=https://bloomberg.bintray.com/pip/simple blpapi==3.14.0
Check the installation by executing python -c "import blpapi", which should pass without displaying messages.
Related
I'm using Python 3.7. I've installed a few packages using pip install. I usually run the scripts I've written directly from the command line, in the Windows Command Prompt.
The other day I installed Visual Studio 2019 Community Edition, mainly for coding C++ console apps. While installing, I noticed it has support for Python, so I checked the box to include the Python features of Visual Studio. I've done nothing further with respect to configuring VS.
Now, when I try to run my Python scripts from the command line, I get a ModuleNotFoundError. For example:
C:\Users\me\Python\MyScript.py
Traceback (most recent call last):
File "C:\Users\me\Python\MyScript.py", line 25, in <module>
import pyvisa.errors
ModuleNotFoundError: No module named 'pyvisa'
Here are the import statements at the top of my script:
# System imports
import sys
import os
import re
import argparse
from enum import Enum
# Third-party library imports
import pyvisa.errors
import pyvisa as visa
The library in question is still installed:
C:\Users\me\Python>pip show pyvisa
Name: PyVISA
Version: 1.10.1
Summary: Python VISA bindings for GPIB, RS232, TCPIP and USB instruments
Home-page: https://github.com/pyvisa/pyvisa
Author: Torsten Bronger, Gregor Thalhammer
Author-email: bronger#physik.rwth-aachen.de
License: MIT License
Location: c:\users\me\appdata\local\programs\python\python37-32\lib\site-packages
Requires:
Required-by:
My path and PYTHONPATH are:
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\me\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\me\AppData\Local\Programs\Python\Python37-32\;C:\Users\me\AppData\Local\Microsoft\WindowsApps;
PYTHONPATH=C:\Users\me\Python\pkg
Here is the sys.path:
C:\Users\me\Python>python -m site
sys.path = [
'C:\\Users\\me\\Python',
'C:\\Users\\me\\Python\\pkg',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\lib',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages',
'C:\\Users\\me\\Python\\common',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\win32',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\win32\\lib',
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-p`enter code here`ackages\\Pythonwin',
]
USER_BASE: 'C:\\Users\\me\\AppData\\Roaming\\Python' (doesn't exist)
USER_SITE: 'C:\\Users\\me\\AppData\\Roaming\\Python\\Python37\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
I've read several of the top Google hits for ModuleNotFoundError, but a simple explanation is not to be found.
What is a straightforward solution to this?
I am trying to run python code which imports GLFW3 library. It gives this error:
''' File ".\run_simulation.py", line 15, in
from modules.graphics.simulator_visualizer import SimulatorVisualizer File
"F:\webapp\p1_aksu_rubius\utils..\modules\graphics\simulator_visualizer.py",
line 2, in
import glfw File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\glfw__init__.py",
line 34, in < module>
raise ImportError("Failed to load GLFW3 shared library.") ImportError: Failed to load GLFW3 shared library. '''
I use Windows Server 2012 R2 and Python version 3.7.4 (64 bit)
I found that there is glfw3.dll file in the directory C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\glfw. Then I add this path into Windows environment variable - PATH. Anyway is does not help. What is the problem?
Thanks!
If the .dll is there (it's in the right place), then it was found. Adding its path to %PATH% won't do anything. It's one (at least) of its dependencies that's missing.
According to [PyPI]: GLFW:
Windows
The GLFW shared library is included in the Python wheels for Windows, but the correct Microsoft Visual C++ Redistributable will be required:
VC 2010 for 32-bit Python, or
VC 2012 for 64-bit Python.
So, you need [MS]: Visual C++ Redistributable for Visual Studio 2012 Update 4 (x64). Select VSU_4\vcredist_x64.exe, download, install it and try again.
Let me know how it works out.
What I currently try to achieve is building a python mapping of my C++ classes through Boost.Python.
After this I want to use the resulting shared library in a blender add-on to be able to take advantage of already existing functionality coming from the mapped C++ classes.
I can already build my shared library and write sample scripts in python, which are using my library as well.
Everything fine here but the problem is that as soon as I try to use it in an add-on, Blender 2.74 keeps crashing all the time as soon as I add an import statement with this little hint in the crash report:
6 libboost_python.dylib 0x000000010aa7cc3e boost::python::detail::init_module(PyModuleDef&, void (*)()) + 30 (module.cpp:44)
In module.cpp inside of boost line 41-46:
BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef& moduledef, void(*init_function)())
{
return init_module_in_scope(
PyModule_Create(&moduledef),
init_function);
}
My boost 1_58 is compiled using Python 3.4.2:
otool -L /usr/local/lib/libboost_python.dylib
/usr/local/lib/libboost_python.dylib:
libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/3.4/Python (compatibility version 3.4.0, current version 3.4.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Running the python3 bin from that directory gives me:
python3
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
The Blender Python console gives me:
PYTHON INTERACTIVE CONSOLE 3.4.2 (default, Nov 25 2014, 12:01:44) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)]
Command History: Up/Down Arrow
Cursor: Left/Right Home/End
Remove: Backspace/Delete
Execute: Enter
Autocomplete: Ctrl-Space
Zoom: Ctrl +/-, Ctrl-Wheel
Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data
>>>
My own project uses this python version as well.
Also Blender uses this Python version.
I really don't know what to try next here since in standalone mode EVERYTHING works as expected.
Also the fact that the crash even occurs as soon as I run a new script inside Blenders Text Editor having the import statement.
Anybody having experience with Boost.Python and Blender?
Thanks in advance
UPDATE:
After building and running blender in debug mode, I got the following state:
This doesn't look right and describes the crash in the first place.
Still searching for the cause...
Blender itself (as well as oiio and osl libs) are built using boost, ensure that the version you use to build boost-python matches the one used by blender. As blender has already loaded boost libs into ram, when you import boost-python it will use the already loaded boost libs not the ones you built boost-python with, if each is a different version it can cause problems, if each is built using different options it can also cause issues.
If you are building blender yourself also build OpenImageIO and OpenShadingLanguage so they use the same boost version. By building them yourself you can ensure they all load the version that you want to use. Check your cmake or sconscript settings point to the same boost lib files.
% ldd blender | grep boost
libboost_filesystem.so.1.55.0 => /usr/local/lib/libboost_filesystem.so.1.55.0 (0x806009000)
libboost_regex.so.1.55.0 => /usr/local/lib/libboost_regex.so.1.55.0 (0x80621e000)
libboost_system.so.1.55.0 => /usr/local/lib/libboost_system.so.1.55.0 (0x806525000)
libboost_thread.so.1.55.0 => /usr/local/lib/libboost_thread.so.1.55.0 (0x806728000)
libboost_date_time.so.1.55.0 => /usr/local/lib/libboost_date_time.so.1.55.0 (0x806942000)
libboost_wave.so.1.55.0 => /usr/local/lib/libboost_wave.so.1.55.0 (0x806b4f000)
libboost_locale.so.1.55.0 => /usr/local/lib/libboost_locale.so.1.55.0 (0x806e94000)
libboost_chrono.so.1.55.0 => /usr/local/lib/libboost_chrono.so.1.55.0 (0x814ee3000)
After a lot of trial and error I got it working!
I'll try to give a step by step tutorial on how to do that for OSX.
In the next couple of weeks I'll also try to get it working on windows and will update this answer as I succeed!
Step 1
Install python 3.4.2 from https://www.python.org/downloads/release/python-342/
Step 2
Checkout the blender git repo and the svn repo from blender (found at http://wiki.blender.org/index.php/Dev:Doc/Building_Blender/Mac):
mkdir ~/blender-build
cd ~/blender-build
git clone http://git.blender.org/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master
Download external libs:
cd ~/blender-build
mkdir lib
cd lib
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/darwin-9.x.universal
Step 3 Use CMake to create the XCode project for building blender
Make sure you check the following settings for python:
This will automatically configure to build blender using the installed python framework on your mac.
Step 4 Download and build boost with the Python 3.4.2
Here you first have to check which version blender uses.
In the external libraries svn repository boost is contained as a pre build library at:
blender-build/lib/darwin-9.x.universal/README
For me this is boost 1.51: http://www.boost.org/users/history/version_1_51_0.html
Step 5 Build your shared library with Boost 1.51 and Python 3.14
Step 6 Build blender and make sure it is using the installed Python 3.4.2
Step 7 Copy your shared library into the addons folder of the blender.app
Here a tiny small little hint: In order to let python recognize your shared library it has to have the extension .so rather than .dylib (for windows this is .pyd rather than .dll)!
Step 8 Recheck
Check that your boost is compiled agains Python 3.4.2:
otool -L /usr/local/lib/libboost_python.dylib
/usr/local/lib/libboost_python3.dylib:
libboost_python3.dylib (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/3.4/Python (compatibility version 3.4.0, current version 3.4.0) <- IMPORTANT
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
You can also check if your library can be used in a simple python script like test.py by executing the following script in a folder were your .so is contained:
import mylib
print('hello world!')
Run:
python3 test.py
Basically now you should also be able to execute this simple script inside of blender, which is the case for me.
I've tried to resolve this prolem for about 3days, and I'd finally felt that I need to ask for help by creating my own question.
I have Windows 7x64 and Qt4.8.6 installed.
I need Python with PyQt and Qscintilla2 to be installed and working.
Now I wil describe my last actions. I did everything like included packages instructions said.
1) Installed Python2.7.9 32bit from official website.
2) Downloaded SIP from here (dev snapshot), then:
configure.py —platform win32-g++
mingw32-make
mingw32-make install
3) Downloaded PyQt from here (not the installer but dev snapshot, cause I need to build with MinGW and istaller producec MSVC version), then:
configure-ng.py -spec win32-g++
mingw32-make
mingw32-make install
Ater these steps I tested PyQt on my project - everything works fine.
Then I starded trying to install Qsnitilla2.
4) Downloaded Qsnitilla2 from here (dev snapshot), then:
a) in Qt4Qt5 folder:
qmake qscintilla.pro -spec win32-g++
mingw32-make
mingw32-make install
This had installed Qsnitilla2 in Qt4.8.6 as I saw;
b) in Python folder( F..ing Python bindngs, excuse my french):
config.py —spec win32-g++
mingw32-make
after this I got ld.exe error (linking error):
Then, afted doing some research, I manually edited my Makefile.Release (by adding -lpython27 to LIBS parameter):
LIBS = -L"c:\Qt-mingw\4.8.6\lib" -LC:\Python27\libs -LC:\Qt-mingw\4.8.6\lib -lqscintilla2 -lQtGui4 -lQtCore4 -lpython27
After this, my mingw32-make completed succesfully. So:
mingw32-make install
This had installed Qscintilla2 Python bindings.
Now I can see Qsci autocomlplete in Eclipse.
So i've tried this:
from PyQt4.Qsci import QsciScintilla
And i've got this in traceback:
from PyQt4.Qsci import QsciScintilla
ImportError: DLL load failed: Не найден указанный модуль
(Translation: The specified module could not be found)
I've tried this with both dev snapshot and src packages from Riverbank website. And also with MinGW 4.8.1 and MinGW-w64 4.8.4. I can't use MinGW-w64 over 4.8 version cause I need boost-1.55 and it only supports MinGW 4.8.
I don't know what to do now, but I really want to use Scintilla in my project. So i'll be very gratefull for any suggestions.
Have you ever tried to load the QsciScintilla right from the console? I mean you need to enter the directory where the QScintilla located( this means current folder is the default folder), then try run the command "from PyQt4.Qsci import QsciScintilla", if this load module failure still happens, this possibly means you need extra dynamic which QScintilla depends, you need to use dll dependency to find out if some other libraries were missing, then put the missing libraries into the same folder of QsciScintilla.
My system is :win7 64 ultimate +python34(64)+intel 64 chip.
I have installed mingw64 ,please see:
C:\Users\pengsir>d:\mingw\bin\gcc -v
Reading specs from d:/mingw/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.2/specs
COLLECT_GCC=d:\mingw\bin\gcc
COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.2/lto-wra
pper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-4.8.2/configure --prefix=/opt/windows_64 --with-sysroot=
/opt/windows_64 --libdir=/opt/windows_64/lib64 --mandir=/opt/windows_64/man --in
fodir=/opt/windows_64/info --enable-shared --disable-bootstrap --disable-multili
b --enable-threads=posix --enable-languages=c,c++ --enable-checking=release --wi
th-system-zlib --with-python-dir=/lib64/python2.7/site-packages --disable-libunw
ind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --e
nable-java-home --with-java-home=/opt/windows_64/lib64/jvm/jre --with-jvm-root-d
ir=/opt/windows_64/lib64/jvm --with-jvm-jar-dir=/opt/windows_64/lib64/jvm/jvm-ex
ports --with-arch-directory=amd64 --with-antlr-jar='/home/adrien/projects/win-bu
ilds-1.4/slackware64-current/d/gcc/antlr-*.jar' --disable-java-awt --disable-gtk
test --build=x86_64-slackware-linux --host=x86_64-w64-mingw32 --target=x86_64-w6
4-mingw32
Thread model: posix
gcc version 4.8.2 (GCC)
when i install with the command:
d:\Python34\Scripts\pip.exe install numpy
(other message ommitted)
error: Unable to find vcvarsall.bat
How to compile the numpy to install on the python34?
I don't want to install vs2013 ,i like free software,no money to pay for vs2013 ,please teach me to complie numpy to install on 64 bits platform mingw64.
Is there some requirement that you build numpy from source? I have always just installed it (and every other Python package that's troublesome on Windows) from Christoph Gohlke's Unofficial Binaries Page, which has always worked perfectly for me.
As per http://shop.wickeddevice.com/2013/12/11/windows-7-python-virtualenv-and-the-unable-to-find-vcvarsall-bat-error/:
For Python 3.4, download Visual C++ 2010 from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
Install it.
Open Windows explorer (the file browser) and search for the location of ‘vcvarsall.bat’ and cut it to your clipboard.
run regedit from the Windows start key. You will need admin privilges.
Add a registry entry to HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (64 bit Windows) or
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir (32 bit)
(If these don't work, try replacing VisualStudio with VCExpress
as described in How do I point easy_install to vcvarsall.bat?
Restart cmd and try again.