Problems with ipywidgets when importing vaex - jupyter

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?

Related

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

Cannot import category encoder due to module error

PLEASE HELP!!
Cannot import category_encoder using Jupyter Notebook This is what I see
It is installed using conda install -c conda-forge category_encoders

Visual Studio Code does not render ipywidgets correctly

I am having issue using Visual Studio Code. the code seem to have issue with ipywidgets.
the code is below (very simple interactive chart)
from ipywidgets import interact
import ipywidgets as widgets
import numpy as np
import plotly.graph_objects as go
#interact
def foo(beta=(-10,10,1)):
myx = np.arange(0,100,1)
myy = myx *beta
print ('debug:',myy)
fig = go.FigureWidget()
fig.add_scatter(x= myx, y=myy)
fig.show()
the same code works just as expected in Jupyter Notebook.
I dig further and it seems:
"widgets require us to download supporting files from a 3rd party website. Error loading plotlywidget: ^4.14.3
https://github.com/microsoft/vscode-jupyter/wiki/IPyWidget-Support-in-VS-Code-Python
This is where I got stuck.. What's the next then to fix this issue?
any guidance much appreciated
thanks
Some of the issues I've seen reported seem to have started after the release of ipywidgets 8.
I don't understand exactly what's broken (or if it's broken), but downgrading to version 7.7.1 fixed all issues I was having.
If you want to try it as well, you can run: pip install -U ipywidgets==7.7.1
There two things you can explore.
Check modules:
Run the jupyter --version command inside your conda or virtual environment.
You should see something like this:
IPython : 8.4.0
ipykernel : 6.9.1
ipywidgets : 7.7.1
jupyter_client : 7.2.2
jupyter_core : 4.10.0
jupyter_server : 1.21.0
jupyterlab : 3.4.8
nbclient : 0.6.4
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : not installed
traitlets : 5.4.0
If there are any of those modules not installed (Apart from qtconsole) try installing them (with pip install "module") and restarting the kernel.
Check Jupyter nbextension.
As mentioned here after running pip install ipywidgets try:
jupyter nbextension enable --py widgetsnbextension
Note: If you are using virtual environments (including conda environments) the recommended way to activate the extension is to run
jupyter nbextension enable --py --sys-prefix widgetsnbextension
I hope this helps.

How to execute the right Python to import the installed tensorflow.transform package?

The version of my Python is 2.7.13.
I run the following in Jupyter Notebook.
Firstly, I installed the packages
%%bash
pip uninstall -y google-cloud-dataflow
pip install --upgrade --force tensorflow_transform==0.15.0 apache-beam[gcp]
Then,
%%bash
pip freeze | grep -e 'flow\|beam'
I can see that the package tensorflow-transform is installed.
apache-beam==2.19.0
tensorflow==2.1.0
tensorflow-datasets==1.2.0
tensorflow-estimator==2.1.0
tensorflow-hub==0.6.0
tensorflow-io==0.8.1
tensorflow-metadata==0.15.2
tensorflow-probability==0.8.0
tensorflow-serving-api==2.1.0
tensorflow-transform==0.15.0
However when I tried to import it, there are warning and error.
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py:12: The name tf.estimator.inputs is deprecated. Please use tf.compat.v1.estimator.inputs instead.
ImportErrorTraceback (most recent call last)
<ipython-input-3-26a4792d0a76> in <module>()
1 import tensorflow as tf
----> 2 import tensorflow_transform as tft
3 import shutil
4 print(tf.__version__)
ImportError: No module named tensorflow_transform
After some investigation, I think I have some ideas of the problem.
I run this:
%%bash
pip show tensorflow_transform| grep Location
This is the output
Location: /home/jupyter/.local/lib/python3.5/site-packages
I tried to modify the $PATH by adding /home/jupyter/.local/lib/python3.5/site-packages to the beginning of $PATH. However, I still failed to import tensorflow_transform.
Based on the above and the following information, I think, when I ran the import command, it executes Python 2.7, not Python 3.5
import sys
print('\n'.join(sys.path))
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/local/lib/python2.7/dist-packages/IPython/extensions
/home/jupyter/.ipython
Also,
import sys
sys.executable
'/usr/bin/python2'
I think the problem is tensorflow_transform package was installed in /home/jupyter/.local/lib/python3.5/site-packages. But when I run "Import", it goes to /usr/local/lib/python2.7/dist-packages to search for the package, rather than /home/jupyter/.local/lib/python3.5/site-packages, so even updating $PATH does not help. Am I right?
I tried to upgrade my python, but
%%bash
pip install upgrade python
Defaulting to user installation because normal site-packages is not writeable
Then, I added --user. It seems that the python is not really upgraded.
%%bash
pip install --user upgrade python
%%bash
python -V
Python 2.7.13
Any solution?
It seems to me that your jupyter notebook is not using the right python environment.
Perhaps, you installed the package under version 3.5,
but the Notebook uses the other one, thus it cannot find the library
You can pick the other interpreter by clicking on: Python(your version) - bottom left.
VS-Code - Select Python Environment 1
However you can do this also via:
CNTRL+SHIFT+P > Select Python Interpreter to start Jupyter Server
If that does not work make sure that the package you are trying to import is installed under the correct python environment.
If not open up a terminal, activate the environment and install it using:
pip install packagename
For example i did the same thing here: (Note: I'm using Anaconda)
installing tensorflow_transform
After a installation, you can import it in your code directly like this:
importing tensorflow_transform

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