For R model registration from jupyter to azure databricks, I was logging the R model using mlflow,
predictor <- crate(function(x) predict(model,.x))
mlflow_log_model( predictor,'MODEL')< facing error here>
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/r-mlflow-1.26.1/lib/python3.7/site-packages/mlflow/utils/databricks_utils.py", line 44, in _get_dbutils
import IPython
ModuleNotFoundError: No module named 'IPython'
when I try to import IPython module using below code:
from IPython import get_ipython
I got below error:
I installed the IPython module using below command:
pip install ipython
I imported ipython module and run the below code:
import IPython
from IPython import get_ipython
from IPython.display import Image
print(Image)
print(IPython.__version__)
It executed successfully with out any error:
Related
I am fairly new to using jupyter notebook, and I've read every forum available for this issue, with no luck.
I am running Windows 11, and I installed Anaconda, then created and activated a virtual environment called pytorchenv. My .yml file includes the following
name: pytorchenv
channels:
defaults
pytorch
dependencies:
numpy=1.16.2
pandas=0.24.2
matplotlib=3.0.3
pillow=5.4.1
pip=19.0
plotly=3.7.0
scikit-learn=0.20.3
seaborn=0.9.0
python=3.7.3
jupyter=1.0.0
pytorch=1.1.0
torchvision=0.2.2
If I list all of the included packages in the command prompt, using
conda list -n pytorch
it shows that pytorch is installed as...
Name Version Build Channel
pytorch 1.1.0 py3.7_cuda100_cudnn7_1 pytorch
What's more, if I enable the virtual environment in the Command Prompt, It seems that I am able to import pytorch successfully
C:\\Users\\Nathaniel\>conda activate pytorchenv
(pytorchenv) C:\\Users\\Nathaniel\>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) \[MSC v.1915 64 bit (AMD64)\] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import torch
>>>
However, when I try to import pytorch into jupyter notebook, I get the message
import torch
ModuleNotFoundError
Traceback (most recent call last)
Input In \[1\], in \<cell line: 1\>()
1 import torch
ModuleNotFoundError: No module named 'torch'
I have been able to import pandas and numpy in jupyter notebook without issue, but I have not figured out a way to import pytorch successfully.
In case this is helpful, jupyter notebook shows that it is running on
Python 3 (ipykernel)
and running the following in jupyter notebook
import sys
print(sys.executable)
results in
C:\\Users\\Nathaniel\\anaconda3\\python.exe
I've tried checking if there were multiple versions of jupyter notebook on my computer (there aren't).
I also checked that pytorch is installed in the same place as my other anaconda packages (it is).
What am I doing wrong?
The notebook is running with your base environment, as indicated by sys.executable.
Two methods:
Start Jupyter from your environment
Register your environment to be usable by all jupyter notebooks
For that you can find the necessary steps here
Basic step is this
source activate pytorchenv # or activate the environment via conda
python -m ipykernel install --user --name pytorchenv --display-name "Python (pytorchenv)"
Afterwards be sure to restart Juypter, then you should be able to select your pytorchenv kernel.
I am running Ubuntu Linux on my laptop, Anaconda 3 with python version 3.6. Jupyter notebook worked fine for me the last time I used it on this computer, but that was 3 months ago. So today I turn it on and try to run jupyter notebook, and I get this error:
john#john-Satellite-L55Dt-B:~$ jupyter notebook
Traceback (most recent call last):
File "/home/john/anaconda3/bin/jupyter", line 7, in <module>
from jupyter_core.command import main
ImportError: No module named jupyter_core.command
I'll admit I'm completely lost and a little rusty with my LINUX, so what do I need to do to make it work?
Try to export the below path and take jupyter noteboo again.Hope this helps.
export PATH= /home/john/anaconda3/bin:$PATH
You can create a conda environment using the below command:
conda create -n env_sample -c intel python=3.6
To activate the environment use the below command:
source activate env_sample
env_sample is the environment name
I am using the reticulate package to import python modules into RStudio.I was able to import packages like cv2,pandas,sklearn but was unable to import the google.cloud.vision package.I have installed this package via pip and am using Anaconda 4.4.0 Python 2.7 version on ubuntu-trusty-14.04-amd64-server on AWS.Pic of the error in R-Studio Server
The Installation of the vision and the language libraries was done via
pip install --upgrade google-cloud-vision
pip install --upgrade google-cloud-language
I am also able to import these modules in the python interactive sessions without any error
>>>import google.cloud.vision
>>>import google.cloud.language
Can somebody please advise me on what I am doing wrong...
Edit 1 :I have tried using the approach that Yuan Tang had suggested.I have installed the requests and httplib2 package in the conda environment.I have also used the use_python command to point Rstudio to the correct python environment.
use_python("/home/avadhut/miniconda2/bin/python")
The cv2 package is installed in the conda environment and it is imported successfully which means RStudio is using the correct Python environment
Even after doing all this I am getting the following trace-back in the R studio console.
Error in py_module_import(module, convert = convert) :
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
Detailed traceback:
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/vision/__init__.py", line 36, in <module>
from google.cloud.vision.client import Client
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/vision/client.py", line 20, in <module>
from google.cloud.client import ClientWithProject
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/client.py", line 25, in <module>
import google.auth.transport.requests
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/auth/transport/requests.py", line 30, in <module>
caught_exc,
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/six.py", line 737, in raise_from
raise value
Here is the pic of my RStudio IDE with the error displayed.
!Reticulate Package Import Error
This is because the Python binary you are using inside RStudio via reticulate does not have those packages (e.g. requests, httplib2, etc) installed.
You can find out what Python reticulate is using via py_config(). You can also find the Python binary you are using on the terminal via which python.
Let's suppose the Python binary you are using on the terminal (the successful imports) is: "/Users/user1/anaconda3/bin/python". Then you use that particular Python binary for reticulate via the following:
use_python("/Users/user1/anaconda3/bin/python")
Then your imports should work as expected.
I've tried to build PyQt from sources (with binary Qt 5.8.0 downloaded) on my Windows 7x64.
I did it by this tutorial: https://stackoverflow.com/a/40779370/2726900
I've entered Visual Studio 2015 Command Prompt, activated vcvarsall.bat amd64, activated qtenv2.bat.
Than I configured, built and installed SIP (no errors).
Than I configured PyQt (just added --sip C:/Python35/sip.exe) and successfully built and installed PyQt.
The filed like QtCore.pyi, QtCore.pyd, QtGui.pyi, QtGui.pyd and so on really appeared in my site-packages/PyQt5 folder.
Bug when I tried to import some modules from my installed PyQt5, it failed.
>>> from PyQt5 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
Cannot you tell me, how can I fix it?
python -m pip install --upgrade pyqt5
I am trying to import the rpy2 (version2.3.4) library into Python (version3.2.3) on a Ubuntu 12.10 machine. The rpy2 documentation says that rpy2 works under all Python 3 versions and I am also finding other topics related to rpy2 and Python3.2 which show that these versions should work together. Anyhow when I try to import a module:
from rpy2 import robjects
the result is this:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "/usr/local/lib/python3.2/dist-packages/rpy2/rinterface/__init__.py", line 8, in <module>
raise RuntimeError("Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2")
RuntimeError: Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2
So, is rpy2 really not working with Python3.2 what would fit to the information the projects is giving me or waht might be the problem.
thx.
The rpy2 documentation says that rpy2 works under all Python 3 versions
Not quite, I hope; check the part about installing rpy2.
Python 3.2 will probably never be supported by rpy2 (Python 3.2 is already EOL). If your are after using Python 3, update to Python 3.3.