How to add seaborn library in jupyter lite static build - jupyter-notebook

I have created the static build of jupyter lite while running seaborn library example code in jupyter lite tool i am getting this error : seaborn module not found.

First of all import matplotlib library then import seaborn library like,
from matplotlib import pyplot as plt
import seaborn as sn
(plt and sn is like rename or short name you can write anything like this place)

Add this at the beginning of your notebook
import piplite
await piplite.install('seaborn')
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
Sample notebook image

Related

No module named 'PyQt6.QtWidgets'

I get the above message when I try to use QtWidgets. Has anyone else had this issue and solved it? Just to clarify I have installed PyQt6 using and there is no issue when I
python3 -m pip install PyQt6
and there is no issue when I try
import PyQt6
so the issue is something to do with QtWidgets.
Since downloading I tried
app = PyQt6.QtWidgets.QApplication([])
and I received the error "ModuleNotFoundError: No module named 'PyQt6.QtWidgets'"
I can't find any information on how to solve this so can anyone help?
I am using macOS 12.5.1 and python 3.9.15.
Try this import statement instead:
import PyQt6.QtWidgets
some packages have kind of 'subpackages'(like QtWidgets) you have to import specifically.
I do not know the reasoning behind this, but it is done in bigger packages.

OR-Tools CP-Sat with Pyinstaller

Model works pretty fine on my pc using VS Code. Once I create an exe with pyinstaller and try to run the .exe nothing works. A small window appears for 1 sec and nothing else. I also tried some tk msg box and nothing happens.
Here are the imports of my main :
import csv
import os
import openpyxl
import sft_gen
from ortools.sat.python import cp_model
The imports of my 2nd file (sft_gen):
import csv
from tkinter import Tk
from tkinter.filedialog import askopenfilename
When I run the .exe in the cmd prompt I get :
Error msg in prompt
Edit.1. : After testing, found out that :
from ortools.sat.python import cp_model
is the reason why the .exe fails to execute.
What could be the solution to this? I really want to deploy my CP model to other users... In the meantime I'll try other .exe apps like py2exe and mention here if I have any success with it.
This was asked before.
From what I understand, pyinstaller does not support python module using native libraries.

Jupyter notebook cannot import caffe

I work with caffe and I can run my python code and train network successfully. but I need to draw some plots interactively during trainig so I try to use jupyter notebook and IPython but jupyter cannot import caffe and raise this error:
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Any suggestion to solve the problem or to live plot without IPython??
Thank you!
Add export PYTHONPATH="${PYTHONPATH}:/caffe/path/caffe/python" to the end of ~/.profile or ~/.bashrc or ~/.bash_profile file.
After adding the above line to the file run source whichever file you have edited.
If your are using bash, ~/.bashrc is to be edited and if your on MAC, ~/.profile to be edited
For only one Jupyter Session
import sys
caffe_root = '/home/basha/caffe/python'
sys.path.insert(0,caffe_root)
import caffe

Pycharm Console - Virtual Environment

I just want to: import numpy as np
from my Pycharm console.
I have set up virtual environments.
I can: import numpy as np in my .py code in my projects.
Is there a way to point my console to a virtual environment?
I know I was able to import numpy as np from my console in the past. I do not know how I broke this or how to fix it.

How to import pyFirmata correctly?

I'm working on a project that involves experimenting with Arduino Mega and I'm learning about it from this book https://books.google.co.uk/books/about/Python_Programming_for_Arduino.html?id=O0PfBgAAQBAJ&printsec=frontcover&source=kp_read_button&redir_esc=y#v=onepage&q&f=false
I'm in a stage where I need to import pyfirmata library but for whatever reason it keeps throwing an import error.
I installed the library using pip3 and when that didn't help I built it from source therefore I'm quite confident that I've got it in my system. I even got a file path where it is installed. Within my Python site-packages directory.
The book is favouring Python 2.7 but I figured I can make this work in Python 3 as well. I tried import pyfirmata, from pyfirmata import Arduino and in both cases I get import error.
It shouldn't be that hard to get this to work. What should I try ?
#!/usr/bin/python
# Import required libraries
import pyfirmata
from time import sleep
I also tried replacing the first line with the exact file path of the directory but no effect.
you did everything needed with python but you also need to open Arduino IDE and press files, examples, Firmata, StandardFirmata then transfer the code to your board. Your board will now easily communicate with Python through the module Pyfirmata.

Resources