Can somebody please help me loading the ipython module into jupyter notebooks?
ipython is a dependency for Jupyter, so it's already installed.
It looks like you're trying to import ipython widgets (ipywidgets) for use in Jupyter. To do this, in your shell (outside of Jupyter) install ipywidgets:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
Then import widgets:
import ipywidgets as widgets
Read the docs to learn more about installing and using ipython widgets.
I believe that part of the problem is the capitalisation of the IPython package in your import statement:
try: import IPython.html.widgets
I don't know if that will get you everything you want, but that's probably the issue regarding your import.
Related
I am using Colab to write a notebook using plotly. Within the notebook everything is fine and I can see the pie, but after converting the notebook into a html I don't see it.
this is the code:
import matplotlib.pyplot as plt
import plotly.express as px
Labels=['No', 'Ex-fumatore', 'Fumatore']
values=[1838, 1293, 574]
fig=px.pie(values = values,names = Labels,hole=.5,title = "Tipologie fumatori In Percentuale")
fig.show()
!jupyter nbconvert --to html /content/pie.ipynb
can somebody help me?
Thanks
There could be various reasons why converting an ipynb file to HTML from Colab is not working properly. Here are some possible solutions you could try:
1. Make sure that you have installed the required libraries in Colab that are needed for conversion. To install nbconvert, run the following command in a new cell:
!pip install nbconvert
2. If the nbconvert library is already installed, try uninstalling and reinstalling it to ensure that you have the latest version. You can uninstall it by running the following command:
!pip uninstall nbconvert
And then reinstall it by running:
!pip install nbconvert
3. Check that your notebook is properly saved and there are no unsaved changes. If there are unsaved changes, try saving the notebook and then converting it again.
4. Check the output of the conversion process for any error messages or warnings. These can help you identify the source of the problem.
5. Try converting the notebook to HTML using a different method. For example, you could download the notebook file to your local machine and then use a local installation of Jupyter Notebook to convert it to HTML.
I am trying to learn NLP using BERT. While trying to import bert model and tokenizer in colab. I am facing the below error.
ImportError: cannot import name '_LazyModule' from 'transformers.file_utils' (/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py)
Here is my code
!pip install transformers==4.11.3
from transformers import BertModel, BertTokenizer
import torch
In order to fix the error.
I tried to upgrade both transformers and torch.
I have tried the solution from the below link:This
Still i am unable to go forward.
Please assist.
Based on these links 1, 2
This should help -
pip install 'lightning-flash[text]' --upgrade
Since the code provided by you is not the cause of the error as it runs on Colab when I tried it hence this might be the culprit in your environment
This is a toy version of a problem I have. I'm trying to use setuptools to compile some Cython code in place, as part of a larger project.
My topdir is test. It contains:
hello_world.pyx
def say_hi():
print('meh')
and setup.py
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("hello.pyx"),
)
If I build these modules in place with python3 setup.py build_ext --inplace, everything works as expected.
But if add an empty __init__.py to my topdir, I get the following error:
copying build/lib.linux-x86_64-3.8/Code/test/hello.cpython-38-x86_64-linux-gnu.so -> Code/test
error: could not create 'Code/test/hello.cpython-38-x86_64-linux-gnu.so': No such file or directory
Why is this happening? And is there a standard way of fixing it? I would like for these compiled Cython modules to live alongside some other C/Python code which is still in development.
what is happening?
The complete description of what is happening can be found in this GitHub issue: https://github.com/pypa/setuptools/issues/3343#issuecomment-1143527672
TL;DR: When you add a __init__.py file in your top folder, it interferes with the way Cython computes the extension's name. This results in an incorrect name (incompatible with your project layout due to a missing folder) and causes setuptools to crash.
And is there a standard way of fixing it?
If you really want to keep the __init__.py file under your top-level project folder[^1], you can explicitly use Extension objects with the proper/correct name instead of relying on the automatic naming algorithm used by Cython:
from setuptools import Extension, setup
from Cython.Build import cythonize
extensions = [Extension("hello", ["hello.pyx"])]
setup(
ext_modules=cythonize(extensions),
)
[^1] Please note that this is not common practice in the Python packaging ecosystem.
I am trying to run this command in Jupyter Notebook: import pyarrow, get the same error: "ModuleNotFoundError: No module named 'pyarrow'
I have installed it already with pip3 and brew also. So when I ran pip3install pyarrow it says requirements are already satisfied. All other libraries I have installed runs with no issues from the same directory.
Thank you.
This is an odd one, for sure. I am not familiar enough with pyarrow to know why the following worked.
From the docs, If I do pip3 install pyarrow and run pip3 list, pyarrow shows up in the list but I cannot seem to import it from the python CLI. Yet, if I also run conda install -c conda-forge pyarrow, installing all of it's dependencies, now jupyter notebook can import it properly.
Are you using a venv? Try running jupyter kernelspec list in your console and make sure your kernel is running in the environment you're expecting it to be.
https://github.com/jupyter/notebook/issues/2359 (discussion about this here)
I have installed pygame and I dont know how to allow my python to read it...
I do
# import modules
import os
import pygame
And I got this: ImportError: No module named 'pygame'
I think you are missing something here. Download the correct package from the pygame website. it should be a .exe. Then, go to your downloads folder. Double-click on the file to run it and follow the on-screen prompts to install pygame. After you have done that, try importing pygame. You don't need to click-and-drag anything. just run the file you downloaded. Let me know if this works.
Assuming you have windows 32 bit, you would download these files:
python 2.7:
http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi
pygame for 2.7:
http://pygame.org/ftp/pygame-1.9.1.win32-py2.7.msi
If you have run the pygame installer, them make sure your python script is not named pygame.
It is a common mistake made by beginners.
When you type
import pygame
the python interpreter first searches the path you are in, and if it does not find the module with the given name, it searches the modules folder. So if you have a file named pygame or your file is named pygame, change it to something else.