Unable to import name '_TPU_AVAILABLE' from 'pytorch_lightning.utilities' - import

I'm trying to import aitexten package to work on a GPT-2 solution. But I'm encountering an error:ImportError: cannot import name '_TPU_AVAILABLE' from 'pytorch_lightning.utilities' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/init.py)
I tried downgrading pytorch to v1.11.0 but that isn't helping too. Please help!

This worked for me in Google Colab. And it's with aitextgen version 0.6.
!pip uninstall -qqy torch torchvision torchtext torchaudio fastai
!pip install -qq torch==1.9.0 pytorch-lightning==1.7.7 aitextgen==0.6.0

I ran into the same problem! I fixed it by downgrading aitextgen.
In the beginning of my notebook, I ran this command:
!pip3 install -q aitextgen==0.5.2
Make sure to restart your kernel.

try this :
pytorch-lightning==1.4.0rc0
torchmetrics==0.6.0
aitextgen==0.5.2

Related

Problems with ipywidgets when importing vaex

I am trying to import vaex after pip installation but the following problem appears an is not solved even after I have done a pip install for the specific 7.6.0 version of ipywidgets in the jupyter notebook where I am (naively typed !pip -upgrade ipywidgets and !pip install ipywidgets==7.6.0).
ContextualVersionConflict: (ipywidgets 7.5.1 (/Users/federiconutarelli/opt/anaconda3/lib/python3.8/site-packages), Requirement.parse('ipywidgets<8,>=7.6.0'), {'ipympl', 'ipyleaflet'})
Is there a way to solve the issue here from jupyter?

Error when installing pycaret (jinja2) on Colab

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

ImportError: cannot import name 'StopLocust' from 'locust.exception'

I'm getting an ImportError attempting to run a Locust/Selenium script: ImportError: cannot import name 'StopLocust' from 'locust.exception'
Is there a package that I need to install?
from realbrowserlocusts import ChromeLocust
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from locust_plugins.users import WebdriverUser
from locust.exception import StopLocust
import os
from locust import TaskSet, task
The output from the Terminal window shows this:
File "c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\realbrowserlocusts\core.py", line 6, in
from locust.exception import StopLocust
ImportError: cannot import name 'StopLocust' from 'locust.exception' (c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\locust\exception.py)
Any ideas?
If you're using Locust 1.0+ there is no StopLocust in locust.exceptions. I'm not sure what it is you're looking to do so I don't know if it's the right thing for you to use, but there is StopUser in there that you should be able to import.
Local environment issue. Re-installing my setup.
After doing some more research I was able to resolve a couple of issues from the import error. Installing locustio solved the import issue and a follow-on issue in attempting to load the locust web page was solved by updating gevent.
So, for the full fix uninstall the current version of locust and install the locustio version. Then upgrade the gevent.
pip uninstall locust
pip install locustio==0.14.6
pip install --upgrade gevent
Realbrowserlocusts isn't compatible with the most recent versions of Locust. Downgrading to version locust 0.13.5 fixed the issue. I'm not sure exactly which of the most recent versions of locust supports realbrowserlocusts. I would like to find out though so I'm running the best of locust versions supporting running with selenium.

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