hi guys recently i've encounter this problem in google colab, and i dont know how to solve this problem
import h2o
h2o.init
data_train = "https://drive.google.com/open?id=14OYzA93IkuKPlkdvXs9Od53HyopgSQ2u"
data_train_df = h2o.import_file(path=data_train)
i following a book that suggest these following codes, but somehow it wont work.
The h2o package is not automatically installed in Google Colab. If you attempt to run import h2o without installing it, you will get the following error.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-accdebc0c7de> in <module>()
----> 1 import h2o
ModuleNotFoundError: No module named 'h2o'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Based on the error message you can then start a new code block and run !pip install h2o to install the package. Then, running import h2o should be successful.
One more thing to keep in mind is that you need to include parentheses to call a function. Running h2o.init will return the description <function h2o.h2o.init>. Try h2o.init() to initialize an h2o cluster.
Edit: The “not connected to a cluster” means you have not initialized a cluster. Try the h2o.init() command again, but using parenthesis so that the function is called and not printed.
Related
I am trying to use the calc module in metpy. I have installed it both via pip and 'conda forge' option. When i run my script in spyder, i get the following error
ImportError: cannot import name 'AuthorityMatchInfo' from 'pyproj._crs' eg Example file path : (~anaconda3/lib/python3.7/site-packages/pyproj/_crs.cpython-37m-x86_64-linux-gnu.so)
Had the same issue two times and solved it by following advice I found on github.
Basically one needs to uninstall pyproj and reinstall.
I am trying to run my first PySpark script on a Linux VM I configured. The error message I have is KeyError: SPARK_HOME when I run the following:
from os import environ
from pyspark import SparkContext
I momentarily made this error go away by running export SPARK_HOME=~/spark-2.4.3-bin-hadoop2.7. I then ran into a new error error=2, No such file or directory. Searching took me to this page:https://community.cloudera.com/t5/Community-Articles/Tutorial-Install-Configure-iPython-and-create-run-PySpark/ta-p/246400. I then ran export PYSPARK_PYTHON=~/python3*. This brings me back to experiencing the KeyError: SPARK_HOME error.
Honestly, I'm stumbling through this, because it's my first time configuring Spark, and using PySpark. I still don't quite understand the ins-and-outs of pycharm, as well.
I expect to be able to run the following basic sample script on this page: https://medium.com/parrot-prediction/integrating-apache-spark-2-0-with-pycharm-ce-522a6784886f with no issues.
there is a package called findspark here
or you may use below code to set path if not found in environment
import os
if 'SPARK_HOME' not in os.environ:
os.environ['SPARK_HOME'] = 'full_path_to_spark_root'
[code continues]
I'm working on a project and I need to use the PyMouse module.
pip install pymouse
installed pymouse correctly, so I assumed all was fine.
However, when importing PyMouse:
from pymouse import PyMouse
I got the following error running my program:
Traceback (most recent call last):
File "4opeenrij.py", line 1, in <module>
from pymouse import PyMouseEvent
File "C:\Users\lcdew\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymouse\__init__.py", line 92, in <module>
from windows import PyMouse, PyMouseEvent
ModuleNotFoundError: No module named 'windows'
I can't seem to figure out what might cause this error message. Any help would be much appreciated.
Additional info:
I'm using Python 3.7 32 bit
Current pip version: 18.1
I have Windows 10
working on a 64-bit operating system
I had I look into this and became puzzled at first, so looked deeper.
It turns out that pymouse is absolutely full of errors. More that I bothered to find.
The error you got is just one of many errors caused by bad coding.
The code says:
from windows import PyMouse, PyMouseEvent
And it should say:
from .windows import PyMouse, PyMouseEvent
Also, PyUserInput, a sister package that is free from the pymouse errors, requires pyhook, which is unsupported by python 3. After a lot of looking around, the conclusion that there is no way around the problems found, except maybe installing a really early version.
You could also try the keyboard module.
You might want to take a look at pynput module. It works on python 3.8, doesn't have any incompatible dependencies, and doesn't seem to have any errors. Once you have the module installed, this page gives some good examples of various ways to manage the mouse.
I am using JModelica 2.1 on Windows, and up until recently I was always able to import pyjmi without any issue. For example, in the IPython console, I would often run the following without issue:
cd C:\mydirectory
from pyjmi import *
However, recently, I accidentally opened a new IPython console and ran the previous code segment without realizing that I already had one opened which was running an optimization problem. Ever since then, the previous code will throw the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-ecb3494d14c4> in <module>()
----> 1 from pyjmi import *
C:\JModelica.org-2.1\install\Python\pyjmi\symbolic_elimination.py in <module>()
21 import scipy
22 import casadi
---> 23 import modelicacasadi_wrapper as ci
24 import itertools
25 from collections import OrderedDict
C:\JModelica.org-2.1\install\Python\modelicacasadi_wrapper\__init__.py in <module>()
----> 1 from modelicacasadi_wrapper import *
C:\JModelica.org-2.1\install\Python\modelicacasadi_wrapper\modelicacasadi_wrapper.py in <module>()
155 SwigPyIterator_swigregister(SwigPyIterator)
156
--> 157 import casadi.casadi_core
158 class Printable(_object):
159 """Proxy of C++ ModelicaCasADi::Printable class."""
ImportError: No module named casadi_core
The curious thing is that the above error only happens when I change the current directory. If instead I don't cd and stay in the default directory (C:\Users\Public\Documents\JModelica.org), then it imports without any problems and works fine afterwards. It only happens with pyjmi (pyfmi for example will import without issue), which seems to suggest that it might be a problem related to environment variables. However, I can't find any problem with them, in all cases the JMODELICA_HOME as well as all other environment variables found with pyjmi.environ seem to work fine.
I tried circumventing the issue by installing JModelica 2.2, however the problem still persists (both with 2.1 and 2.2). It should be noted however that I didn't uninstall JModelica 2.1 when doing this.
If anybody has any idea about what is causing this behaviour, I would be very grateful.
Edit:
Things have taken a turn for the worst, and now I cannot import pyjmi under any circumstances whatsoever when using JModelica 2.1 (whereas the previous behaviour still holds with JModelica 2.2). I don't know what exactly has changed to cause this.
It turns out that the problem was that I had a Python script named casadi.py (and casadi.pyc along with it) in a folder in my C:\ drive. This script was completely unrelated to JModelica's casadi module. The order of the paths in sys.path made it such that, if the current directory wasn't C:\JModelica.org-2.2, it would find the unrelated casadi.pyc before finding the actual module I wanted. To fix the problem I simply renamed the unrelated script, though I imagine that manually changing the contents of sys.path would have done the trick as well.
I am pretty new to ipython and still learning and liking its functionality. Trying to write a module with common tasks so users of a notebook can load my custom module and save typing common code.
Here is a sample mymodule.ipy:
import mymodule as mymod
mymod.func():
wd=%pwd
return wd
When I test it in the notebook:
import mymodule as my
---------------
ImportError Traceback (most recent call last)
<ipython-input-1-1036e4702cf4> in <module>()
----> 1 import mymodule as my
ImportError: No module named mymodule
But when I rename the module file as mymodule.py, the module load fails with error message denoting it cannot recognize the pwd magic:
File "mymodule.py", line 2
wd=%pwd
^
SyntaxError: invalid syntax
My question is how do I write a module with ipython magics and other ipython functionality in it which I can load from notebooks? I had the impression that I can put ipython code into a file with .ipy extension and can load it from ipython. Am I missing something?
"%run mymodule.ipy" as pointed in my comment serves my need for now. Posting it as answer to close this question. Feel free to post more if you have a "module" approach.