I am currently using Python 2.7 and my OS is Windows 7. While attempting to use the Bloomberg API I am getting this error:
Traceback (most recent call last):
File "datagrab.py", line 1, in <module>
import blpapi, time, json
File "C:\Python27\lib\blpapi\__init__.py", line 5, in <module>
from .internals import CorrelationId
File "C:\Python27\lib\blpapi\internals.py", line 50, in <module>
_internals = swig_import_helper()
File "C:\Python27\lib\blpapi\internals.py", line 42, in swig_import_helper
import _internals
ImportError: No module named _internals
I have set my path variable to point to blpapi3_64.dll and also updated my bloomberg terminal. I have also moved the local blpapi API to a different directory but still the problem exists.
I am kind of new to this API in general. So can someone please guide me?
Thank you in advance!
From your question is sounds like maybe you have tried this, but just outlining one possible solution from the README in the Python Supported Release release available here.
Note that many Python installations add the current directory to the
module search path. If the Python interpreter is invoked from the
installer directory, such a configuration will attempt to use the
(incomplete) local blpapi directory as a module. If the above
import line fails with the message Import Error: No module named
_internals, move to a different directory before invoking python.
I know this question is a bit stale, but in case people end up here like me. Do you have the C++ version of blpapi? it is a requirement for the python api as mentioned here: https://www.bloomberg.com/professional/support/api-library/
so download the C++ zip installer, extract somewhere, and then add it as an environment variable so that the python api can find it:
Environment variable name: BLPAPI_ROOT
Value: C:\blp\blpapi_cpp_3.8.18.1 (THIS IS WHERE MINE IS INSTALLED, YOUR VALUE HERE MAY BE DIFFERENT)
Hope that helps!
Related
I'm trying to build the PiPhone ^1, but when I execute python piphone.py, I receive the following:
I cannot seem to find anyone else who has experienced this problem. What are ways you all suggest I resolve this?
https://github.com/climberhunt/PiPhone
I've used pip uninstall serial but I haven't gotten very far solution-wise.
Traceback (most recent call last):
File "ttest.py", line 2, in <module>
import serial
File "/home/pi/.local/lib/python2.7/site-
packages/serial/__init__.py", line 10, in <module>
from . import utilities, abc, model, marshal, errors,
properties, meta, hooks, test, request
File "/home/pi/.local/lib/python2.7/site-
packages/serial/model.py", line 11, in <module>
from .utilities.compatibility import backport,
BACKWARDS_COMPATIBILITY_IMPORTS
ImportError: No module named utilities.compatibility
You installed the wrong package. You have installed serial, which is a Python package to handle object serialisation and deserialisation from and to YAML, JSON and XML and appears to be broken at the moment (I don't think the author is all that experienced in Python package development yet). Someone else already filed an issue with the package to have it renamed.
You want to install pyserial instead, which is a library to handle serial port connections.
I tried to download Graphlab from Turi wit the following tutorial. I coded with their tools and tried to compute a Python script but it answered me an ImportError.
(gl-env)ubuntu#ip-172-hey-hey-hey:~/Eclipse-Stats$ source deactivate
discarding /home/ubuntu/anaconda2/envs/gl-env/bin from PATH
ubuntu#ip-172-hey-hey-hey:~/Eclipse-Stats$ unset PYTHONPATH
ubuntu#ip-172-hey-hey-hey:~/Eclipse-Stats$ python Main.py
2017-07-27 14:56:00.520425
/home/ubuntu/.local/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "Main.py", line 3, in <module>
import prediction
File "/home/ubuntu/Eclipse-Stats/prediction.py", line 1, in <module>
from graphlab.toolkits.recommender import ranking_factorization_recommender
ImportError: No module named graphlab.toolkits.recommender
Actually it cames often on the server when I tried to download with pip numpy, scipy, sklearn... Like we can see in the following conversation (in Spanish) between FJSevilla and the man of my team I'm working with.
Two things: (1) check the version of your Python console and see if it matches or is higher than the compatibility with the packages. If you look at the depreciation message and read it through, you would understand what is going on a little more. (2) be careful of what you are importing and how you import them because your formatting might also be a syntactic all error. One thing you could do is find the package, manually download, unzip, then run the setup.py.
Why I am getting this error, when I try to run it through python corenlp.py?
Traceback (most recent call last):
File "corenlp.py", line 23, in (module)
from winpexpect import winspawn
File "C:\Python27\1ib\site-packages\winpexpect-1.5-py2.7.egg\winpexpect.py", 1ine 391, in (module)
class winspawn(spawn):
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
But, When i use it in PythonShell GUI, it is working perfectly.
from winpexpect import winspawn
child = winspawn('java -cp "C:\\Python27\\Scripts\\stanford-corenlp-full-2014-08-27\\*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,dcoref -ner.model edu/stanford/nlp/models/ner/english.all.3class.caseless.distsim.crf.ser.gz')
You are getting this error locally because your Python27 doesn't have a prerequisite component installed. In particular it needs Pywin32 installed. You need to download and install Pywin32 from here (specifically the 2.7 version in your case). PythonShell GUI must have this extension already installed so it works.
Finally I was able to resolve my problem(Thanks to #MichaelPetch). I tried this simple example test.py
from winpexpect import winspawn
child=winspawn("java")
It was working fine. Then I realized something wrong with my imports or dependencies. I was using wexpect.py which is another alternative for windows. I renamed it to pexpect.py and copied to my code base.
But winpexpect has dependencies for pexpect(it has another pexpect file on its own folder). When I try to run my .py through cmd it is referring the file in the same folder which is pexpect, I just renamed.
Solution: I just removed wexpect.
I am trying to run a web2py application. Using python2.7 it is running fine.
But I want to use python higher version. When I try with python3.0 or 3.1, am getting an error as
Traceback (most recent call last):
File "/var/www/vhosts/astrozon/web2py/web2py.py", line 18, in <module>
import gluon.widget
File "/var/www/vhosts/astrozon/web2py/gluon/__init__.py", line 15, in <module>
from globals import current
ImportError: No module named globals
I have checked, the module gobals is present in the same folder. and python2.7 is able to import that module but not for 3.0 or 3.1.
I would greatly appreciate any suggestions.
web2py is not compatible with Python 3, and there are no plans to make it so, as that would break its promise to maintain backward compatibility. There have been a couple of experimental attempts at Python 3 forks, but I do not believe they have been maintained. Work has started on a web3py (not the official name) that will be Python 3 compatible, but that is a completely new framework and still in the early stages of development (there is a plan to include a compatibility layer allowing web2py applications to run under it).
I've already asked this question in the "gis.stackexchange" forum, but it seems to be more appropriate for this one.
I am having problems with Python Shell importing the module "qgis.core".
When I type "import qgis.core" the Shell ("idle.pyw") gives me this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import qgis.core
ImportError: DLL load failed: Impossibile trovare il modulo specificato (Trad "Impossible to find the specified module").
I have already set the environment to point the right folders following "PyQGIS cookbook" instructions.
In my case, the paths are:
PYTHOPATH=C:\"QGIS_path"\apps\qgis\python;
Path=C:\"QGIS_path"\apps\qgis\bin.
Am I missing something? What are supposed to be the right libraries the Shell is unable to find?
I am working with windows 7 64 bit, QGIS Lisboa (version 1.8), Python 2.7.2 (the one that is included in the QGIS package).
I do not like to mix my python installations, so I add the paths on the fly.
The paths you need are below:
import sys
sys.path.extend([r"C:\Program Files\QGIS Valmiera\apps",r"C:\Program Files\QGIS Valmiera\apps\qgis\bin",r"C:\Program Files\QGIS Valmiera\apps\Python27"])
import qgis.core
Check this link import-qgis-core-in-pycharm-no-module-named-pyqt5-qtcore
also ignore the pycharm setup if you want.
It works for me,
setup-qgispy.bat
#ECHO off
set OSGEO4W_ROOT=C:\QGIS
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis
set GDAL_FILENAME_IS_UTF8=YES
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python37\lib\site-packages;%PYTHONPATH%
set QT_QPA_PLATFORM_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\Qt5\plugins\platforms
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis
and then,
C:\> setup-qgispy.bat
C:\> python file.py
I think instead of sys.path.extend(). Copy the sys.path from qgis python console and use it. Hope this will work.