Error when installing pycaret (jinja2) on Colab - classification

I'm trying to use pyCaret on Colab. This is the setup:
!pip install pycaret
from pycaret.classification import *
grid = setup(data=s, target=s.columns[-1], html=False, silent=True, verbose=False)
best_model = compare_models()
However, I get this error on from pycaret.classification import *:
ImportError: Missing optional dependency 'Jinja2'. DataFrame.style requires jinja2. Use pip or conda to install Jinja2.
I've already followed this instruction unsuccessfully. Unable to resolve import error from PyCaret
Any clue?

If anyone else facing this issue and if its not work like author said try ;
pip install pycaret --user
after execution of code chunk done click *restart runtime button. after install if its succesfully import libraries skip markupsafe phase.
pip install markupsafe==2.0.1
after execution of code chunk done click *restart runtime button.
import jinja2
from pycaret.classification import *

You can also just install Jinja2 manually to solve this problem:
https://github.com/pycaret/pycaret/issues/2490

Related

Cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed'

I am using VQGAN+CLIP_(Zooming)_(z+quantize_method_with_addons).ipynb Google Repository and when I click the cell "Loading of libraries and definitions"
It sent an error :
ImportError Traceback (most recent call last)
<ipython-input-6-fe8fafeed45d> in <module>
24 from omegaconf import OmegaConf
25 from PIL import Image
---> 26 from taming.models import cond_transformer, vqgan
27 import torch
28 from torch import nn, optim
1 frames
/content/taming-transformers/main.py in <module>
10 from pytorch_lightning.trainer import Trainer
11 from pytorch_lightning.callbacks import ModelCheckpoint, Callback, LearningRateMonitor
---> 12 from pytorch_lightning.utilities.distributed import rank_zero_only
13
14 from taming.data.utils import custom_collate
ImportError: cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py)
I don't know how to solde this problem. I don't know how to manually install Pytorch as it said "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."
Thank you in advance if you have the solution.
Inès
I triad !pip install but I may not really know where to put this cell/line of code
pytorch_lightning has recently released a new version which will throw this error (version 1.8.0.post1 released on November 2nd 2022).
https://pypi.org/project/pytorch-lightning/#history
Just install an older version of pytorch_lightning and it will work.
In my system, I ran "pip install pytorch-lightning==1.6.5", higher versions may work as well, you can check them out by clicking on the link provided above and then clicking on release history.
Finally, after long research, I found the solution for it, try to run it, you will face an issue with CLIP module, once you resolve python issue as well, so for that follow the second code.
conda install pytorch-lightning -c conda-forge
Once you clone it, try to follow below command
Step:1 cd CLIP
Step2: python setup.py
after that,
type: cd..
Once you do that, you will be redirected to previous directory named "VQGAN-CLIP"
and finally, run the following command:
python generate.py -p "A painting of an apple in a fruit bowl"
Once it is done, then run your generate python file, It will work fine.
use #vishisht-rao solution to downgrade the package version of pytorch-lightning to 1.7.7; this step by itself did not solve the problem for me.
pip install pytorch-lightning==1.6.5
run pip list|grep lightning to find the installed version of lightning-utilities. Mine was lightning-utilities==0.4.2
Downgrade the package version of lightning-utilities to 0.4.0
pip install lightning-utilities==0.4.0
Downgrading the package versions of both pytorch-lightning and lightning-utilities solved the problem for me.

[Google Colaboratory]: Why can't I use and import a module/package after installing it from Github?

I installed the ismrmrd-python-tools succesfully after running the following command on Colab:
!pip install git+https://github.com/ismrmrd/ismrmrd-python-tools.git
Successfully built ismrmrd-python-tools
But when I want to import the module, I get the next message error:
ModuleNotFoundError: No module named 'ismrmrd'
I tried with other module names like 'ismrmrd-python-tools', 'ismrmrdtools', etc. as well.
Does someone know anything about what could possibly be happening here?
I try it and it works without any problems.
!pip install git+https://github.com/ismrmrd/ismrmrd-python-tools.git
import ismrmrdtools

Unable to import module in Google Colab after installing

I was trying to clone and install the Google Unrestricted adversarial examples repository following the instructions provided here. But I am unable to import the any of the modules. First I cloned the repository and changed to that directory.
!git clone https://github.com/google/unrestricted-adversarial-examples.git
cd unrestricted-adversarial-examples
Then I used the pip install command.
!pip -e install bird-or-bicycle
The installation completed without any error. However, when I try to import I get the 'module not found error'. Could anyone tell me what I am doing wrong? I tried the same commands on my PC and it works.
import bird_or_bicycle
ModuleNotFoundError: No module named 'bird_or_bicycle'
I just got the solution after posting an issue to the repository. The solution was simple, all I needed to do was restart the Colab kernel (Restart Runtime option in the Runtime tab) after !pip -e install bird-or-bicycle Apparently that is required to pick up the newly installed package.
If you look at the bird-or-bicycle docs, you see that there is a data download step required after you pip install.
If you follow the instructions there and run the following in a notebook cell, then the import will work:
!git clone https://github.com/google/unrestricted-adversarial-examples
!pip install -e unrestricted-adversarial-examples/bird-or-bicycle
!bird-or-bicycle-download

how to import h5py on datalab?

Does anybody know how to install h5py on datalab? pip install h5py doesn't work. apt-get install python-h5py is working in the shell but it doesn't recognize the package in datalab notebook!
Thnaks
It is true that !pip install h5py wil allow you to install the library but unfortunately, even after a successful installation, the import will fail:
The issue is rooted on an ongoing python-future issue ("surrogateescape handler broken when encountering UnicodeEncodeError") that is experienced in datalab because the underlying OS uses an 'ANSI_X3.4-1968' file system encoding.
As a hacky workaround, you may remove line 60 from h5py's __init__.py by running the following command from within a notebook cell:
!sed -i.bak '/run_tests/d' /usr/local/lib/python2.7/dist-packages/h5py/__init__.py
Just make sure you run it using bash syntax: !pip install h5py in any notebook cell.

Install BeautifulSoup, mrjob, pattern, and seaborn on python 2.7 on Jupyter

I am learning how to use the new Jupyter. I want to install packages:BeautifulSoup, mrjob, pattern, and seaborn on python 2.7. I first tried to do so by running pip install BeautifulSoup mrjob pattern seaborn That all returns: SyntaxError: invalid syntax
I also tried from bs4 import BeautifulSoup, it did work for Beautifulsoup. But I still don't know how to install other packages.
Wondering anyone know why there was syntax error for using pip install? Is that because I haven't installed pip on python 2.7?
I was also able to install these packages from iphython notebook window by running
import pip
def install(package):
pip.main(['install', package])
install('BeautifulSoup4')
Have you tried installing one package at a time. This helps you find which installation command not working.
You can find Julia packages here.
The problem was I was running pip from inside Jupyter. However, Jupyter is a command line program. Thanks to Mwaskom, the solution is run it from a terminal using:
pip install BeautifulSoup mrjob pattern seaborn
You could try:
!pip install BeautifulSoup mrjob pattern seaborn