Initializing H2O in Python - python

When trying to initialize H2O in Python by running the lines:
import h2o
h2o.init()
I getting the exceptions:
Traceback (most recent call last):
File "C:/workspace/DataScience/univariate_analysis/prudential_RF.py", line 4, in
h2o.init()
File "C:\Anaconda\lib\site-packages\h2o\h2o.py", line 668, in init
H2OConnection(ip=ip, port=port,start_h2o=start_h2o,enable_assertions=enable_assertions,license=license,max_mem_size_GB=max_mem_size_GB,min_mem_size_GB=min_mem_size_GB,ice_root=ice_root,strict_version_check=strict_version_check)
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 101, in __init__
raise EnvironmentError, message
EnvironmentError: Version mismatch. H2O is version 3.2.0.9, but the python package is version 3.6.0.8.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Anaconda\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 565, in end_session
H2OConnection.delete(url_suffix="InitID")
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 393, in delete
return __H2OCONN__._do_raw_rest(url_suffix, "DELETE", None, **kwargs)
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 483, in _do_raw_rest
.format(http_result.status_code,http_result.reason,method,url,detailed_error_msgs))
EnvironmentError: h2o-py got an unexpected HTTP status code:
404 Not Found (method = DELETE; url = http://localhost:54321/3/InitID).
detailed error messages: DELETE /3/InitID not found
Error in sys.exitfunc:
Traceback (most recent call last):
File "C:\Anaconda\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 565, in end_session
H2OConnection.delete(url_suffix="InitID")
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 393, in delete
return __H2OCONN__._do_raw_rest(url_suffix, "DELETE", None, **kwargs)
File "C:\Anaconda\lib\site-packages\h2o\connection.py", line 483, in _do_raw_rest
.format(http_result.status_code,http_result.reason,method,url,detailed_error_msgs))
EnvironmentError: h2o-py got an unexpected HTTP status code:
404 Not Found (method = DELETE; url = http://localhost:54321/3/InitID).
detailed error messages: DELETE /3/InitID not found
Please note I have followed the installation steps in this link Use H2O directly from Python

You have a version mismatch between your h2o python code and your h2o java code.
If you download a fresh version of h2o, make sure you also do a pip install with the same version number. Don't use a generic pip install... rather specify the url and version explicitly.
Download the java package and start the java jar:
But then also click the install python link to get the corresponding pip install command:
Notice that this line needs to match the java version number that you just installed:
pip install http://h2o-release.s3.amazonaws.com/h2o/reltibshirani/8/Python/h2o-3.6.0.8-py2.py3-none-any.whl
Then try again:
import h2o
h2o.init()
Hope this helps!

EnvironmentError: Version mismatch. H2O is version 3.2.0.9, but the python package is version 3.6.0.8.
It looks like you have an instance of 3.2.0.9 already running and the Python package, which is 3.6.0.8, is complaining due to incompatibility.
I recommend you kill the current running instance of H2O (the 3.2.0.9 version that you see in the error message) and run the same commands (import h2o, h2o.init) to drive H2O from Python cleanly.

Related

Miniconda in Mac Book - x array issues

I installed the last version of Miniconda and created a new environment.
I have pip installed the following repos:
pip install git+https://git.ufz.de/FINAM/finam.git
pip install git+https://git.ufz.de/FINAM/finam-netcdf.git
pip install git+https://git.ufz.de/FINAM/finam-plot.git
pip install git+https://git.ufz.de/FINAM/finam-graph.git
Finally, I cloned this repo
git clone https://git.ufz.de/FINAM/finam-examples.git
In that repo I ran two files component.py and pet_calculator.py located at:
~/finam-examples/01_Hargreaves-Samani/src/
I first ran component.py, and that was ok.
The problem came when I ran pet_calculator.py.
This is my error:
(test) sh-3.2$ /Users/lealroja/miniconda3/envs/test/bin/python /Users/lealroja/Documents/UFZ/finam_project/finam-examples/01_Hargreaves-Samani/src/pet_calculator.py
2023-02-19 23:09:44,109 INFO: init composition - FINAM
Traceback (most recent call last):
File "/Users/lealroja/Documents/UFZ/finam_project/finam-examples/01_Hargreaves-Samani/src/pet_calculator.py", line 49, in <module>
composition.initialize()
File "/Users/lealroja/miniconda3/envs/test/lib/python3.11/site-packages/finam/schedule.py", line 148, in initialize
mod.initialize()
File "/Users/lealroja/miniconda3/envs/test/lib/python3.11/site-packages/finam/sdk/component.py", line 65, in initialize
self._initialize()
File "/Users/lealroja/miniconda3/envs/test/lib/python3.11/site-packages/finam_netcdf/reader.py", line 191, in _initialize
self.dataset = xr.open_dataset(self.path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lealroja/miniconda3/envs/test/lib/python3.11/site-packages/xarray/backends/api.py", line 510, in open_dataset
engine = plugins.guess_engine(filename_or_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lealroja/miniconda3/envs/test/lib/python3.11/site-packages/xarray/backends/plugins.py", line 177, in guess_engine
raise ValueError(error_msg)
ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
https://docs.xarray.dev/en/stable/user-guide/io.html
I have that error when using a Mac book Pro. However, when I do the exact same procedure and run it in Ubuntu I have no issues.
I am not an expert, and therefore I have no idea what to do. Could you please help me?
I have tried answers from this links:
IO backend error in the xarray for netcdf file
ValueError: found the following matches with the input file in xarray's IO backends: ['netcdf4', 'h5netcdf']
Thank you in advance.

Numpy not importing

When i try to import numpy to my python file it says:
Traceback (most recent call last):
File "c:\src\Python\Raycast_Test_1\test.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
(i just found some things in the pip help thingy so i did them and this is what i got)
and when i do pip search numpy this shows up:
ERROR: Exception:
Traceback (most recent call last):
File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 224, in _main
status = self.run(options, args)
File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\commands\search.py", line 62, in run
pypi_hits = self.search(query, options)
File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\commands\search.py", line 82, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "c:\users\marti\appdata\local\programs\python\python38\lib\xmlrpc\client.py", line 1109, in __call__
return self.__send(self.__name, args)
File "c:\users\marti\appdata\local\programs\python\python38\lib\xmlrpc\client.py", line 1450, in __request
response = self.__transport.request(
File "c:\users\marti\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\network\xmlrpc.py", line 46, in request
return self.parse_response(response.raw)
File "c:\users\marti\appdata\local\programs\python\python38\lib\xmlrpc\client.py", line 1341, in parse_response
return u.close()
File "c:\users\marti\appdata\local\programs\python\python38\lib\xmlrpc\client.py", line 655, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32500: "RuntimeError: PyPI's XMLRPC API has been temporarily disabled due to unmanageable load and will be deprecated in the near future. See https://status.python.org/ for more information.">
and when i do pip check numpy this shows up:
No broken requirements found.
i have tried uninstaling the installing numpy but that didnt fix it.
How do i fix this?
(note i am using the vscode terminal for this)
pip install numpy --upgrade
or
pip install numpy --upgrade --ignore-installed
Just to make sure you are running correct pip, try running "pip -V" or "pip --version", it gives you which version of python it refers to. Its also possible that you might have pip for say python 2.7, pip3 for python 3.6, and pip3.7 for python 3.7, if you have multiple versions of python installed. For simplicity you can set the most frequently used pip version as pip by setting an alias in ~/.bashrc. This is done by adding the following line in bashrc:
alias pip=pip3.6.
After this you can try and install the packages and import it swiftly.

Python external on Azure ImportError No Module Found

If i locally run my code with python main.py, then this error occurs locally. If i run it with python3 main.py, it works as expected. I suspect my azure app service is not running the correct version of python, however, it is set to python 3.4
StdErr:
2018-06-30 19:47:13.785205: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python34\Scripts\wfastcgi.py", line 541, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 120, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 89, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "main.app" could not be imported: Traceback (most recent call last):
File ".\ptvs_virtualenv_proxy.py", line 73, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File "D:\home\site\wwwroot\main.py", line 2, in <module>
from newspaper import Article
ImportError: No module named 'newspaper'
UPDATE
So I went to the debug console in kudo and i ran python
-m pip install --upgrade -r d:\home\site\wwwroot\requirements.txt.
Here is the error
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt
One of the requirements is Pillow which requires libxml2 and libxslt. I've tried using wheels however, I've had no success.
UPDATE II
I tried to install virtualenv since it does not exist and I receive a permissions error.
UPDATE III
I ran this command
D:\home\python364x64>python -m pip install newspaper3k
I test everything locally, and it works perfect. I push and receive this error below.
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\app.py", line 8, in <module>
from newspaper import Article
File "D:\home\python364x64\lib\site-packages\newspaper\__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "D:\home\python364x64\lib\site-packages\newspaper\api.py", line 12, in <module>
import feedparser
File "D:\home\python364x64\lib\site-packages\feedparser.py", line 316
raise KeyError, "object doesn't have key 'category'"
^
SyntaxError: invalid syntax
StdOut:
StdErr:
Per my experience, we have no permission to modify D:\home environment.
So , It's better to use python extension. Please follow the steps in this case: Azure Flask Routes Not found and use command python -m pip install newspaper to install additional packages in python extension.
Please make sure the package you want to install must match with version of python extension. Otherwise, it will throw error as follows.
Hope it helps you.

Error during Nova compute package installation

Error in command: python setup.py install
I am not getting the error. Please help
This is the error
>bash-4.2# python setup.py install
>ERROR:root:Error parsing
Traceback (most recent call last):
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/core.py", line 104, in pbr
attrs = util.cfg_to_args(path)
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/util.py", line 238, in cfg_to_args
>pbr.hooks.setup_hook(config)
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/__init__.py", line 27, in setup_hook
metadata_config.run()
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/base.py", line 29, in run
self.hook()
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/hooks/metadata.py", line 28, in hook
self.config['name'], self.config.get('version', None))
File "/sagar/nova/pbr-0.10.7-py2.7.egg/pbr/packaging.py", line 554, in get_version
raise Exception("Versioning for this project requires either an sdist"
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed? error in setup command:
Error parsing /sagar/nova/setup.cfg:
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?
I think you haven't added git in PATH variable. I was facing similar issue myself while installing nova on Hyper V. Just updating the PATH variable did the trick

python: pandas install errors

I have the academic distribution of EPD 7.1 for MacOS 10.6.x, which has pandas 0.3 version. The latest official version is 0.5.0 so I though I would upgrade to the latest.
Here is what I did:
saved the zip file of the source from here
executed sudo python setup.py install
ran tests by executing nosetests pandas
Please keep in mind I am a total newbie to python. Any insights on why my install failed would be greatly appreciated. Below is a snippet of the errors. The entire log can be found at Error log
Results:
Ran 1498 tests in 55.011s
FAILED (SKIP=4, errors=91, failures=14)
======================================================================
ERROR: test_generate (test_daterange.TestGeneration)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/core/tests/test_daterange.py", line 20, in test_generate
rng2 = list(generate_range(START, END, timeRule='WEEKDAY'))
TypeError: generate_range() got an unexpected keyword argument 'timeRule'
#wesm - thanks for your quick reply. Next time I will definitely use the mailing list. So I actually backtracked... installed the official 0.5.0 release and compiled from source. I received 3 errors (see below). I did not experience any problems running sudo python setup.py install
======================================================================
ERROR: testForSeries (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 472, in testForSeries
self.series_x, self.series_y)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 565, in checkForSeries
reference = ols(y=series_y, x=series_x, **kwds)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
======================================================================
ERROR: testNonPooled (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 522, in testNonPooled
self.checkNonPooled(y=self.panel_y, x=self.panel_x)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 528, in checkNonPooled
result = ols(y=y, x=x, pool=False, **kwds)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/plm.py", line 780, in __init__
nw_overlap=nw_overlap)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
======================================================================
ERROR: test_auto_rolling_window_type (pandas.stats.tests.test_ols.TestPanelOLS)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/tests/test_ols.py", line 604, in test_auto_rolling_window_type
window_model = ols(y=y, x=data, window=20, min_periods=10)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/interface.py", line 133, in ols
return klass(**kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 521, in __init__
OLS.__init__(self, y=y, x=x, **self._args)
File "/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas/stats/ols.py", line 36, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named api
Best place to ask this question would be on the mailing list (luckily Google Alerts let me know about this right away!). It looks like your install failed and it's still using pandas 0.3.0. Were there any errors when you ran python setup.py install? You may have to upgrade your Cython installation if you're building from a git snapshot (sudo easy_install -U Cython). If that doesn't work, try nuking your existing pandas install:
sudo rm -rf /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/pandas
and reinstalling. The tarball on PyPI includes pre-built Cython sources. If you're building from source anyway I recommend building from the head revision on git anyway. I'm days away from releasing pandas 0.6.0.
The problem was resolved by:
1) installing the pandas 0.6.0 release which Wes made available November 25/2011.
2) removing the existing scikits package, which is bundled with EPD 7.1 (version 0.2) and installing the latest release using 'easy_install -U scikits.statsmodels'.
The above were suggestions made by Wes and folks on the pystatsmodel mailing list (thank you to all).

Categories