ModuleNotFoundError: No module named 'tkfilebrowser' - python

I am trying a code to make a GUI but I keep on getting an error ModuleNotFoundError: No module named 'tkfilebrowser'.
There is a problem I get in the code that Unable to import 'tkfilebrowser'.
from PIL import Image
import tkinter
import tkinter.ttk
from tkinter import filedialog
from tkfilebrowser import askopendirname, askopenfilename, asksaveasfilename
def gendat(data):#convert data into binary data
newd=[]
for i in data:
newd.append(format(ord(i),'08b'))
return newd
def modpix(pix,data):#To return the modified pixels
datalist=gendat(data)
lendata=len(datalist)
imdata=iter(pix)
for i in range(lendata):
pix=[value for value in next(imdata)[:3] + next(imdata)[:3] + next(imdata)[:3]]
for j in range(0,8):
if (datalist[i][j]=='0') and (pix[j]%2!=0):
if (pix[j]%2!=0):
pix[j]-=1
elif (datalist[i][j]=='1') and (pix[j]%2==0):
pix[j]-=1
#0 means keep reading; 1 means the message is over.
if i==lendata-1:
if pix[-1]%2==0:
pix[-1]-=1
else:
if pix[-1]%2!=0:
pix[-1]-=1
pix=tuple(pix)
yield pix[0:3]
yield pix[3:6]
yield pix[6:9]
def encode_enc(data):
s2=tkinter.Tk()
name=askopenfilename()
image=Image.open(name,'r')
global newimg
newimg=image.copy()

hello according to the tkfilebrowser pypi describtion it is an alternative to a native tkinter module and need to be installed independently try
pip install tkfilebrowser
for more info
https://pypi.org/project/tkfilebrowser/

Related

ERROR PYTHON: name 'cairosvg' is not defined

I alredy have a problem.
Show cairosvg as undefined. I wish save Turtle object as png.
I already installed the canvasvg and cairosvg libraries, but even so I keep getting the error. I leave my code as a sample. Thank you
from turtle import *
import os
import shutil
import tempfile
import canvasvg
from canvasvg import *
screen=Screen()
setup (640,520,0,0)
title("T")
tracer(0,0)
encendido='#51D1F6'
apagado='#922B3E'
pant=Turtle(visible=False)
pant.hideturtle()
pant.pensize(4)
pant.penup()
pant.goto(110,0)
pant.pendown()
pant.pendown()
pant.fillcolor(encendido)
pant.begin_fill()
pant.goto(-400,-180)
pant.goto(-400,-190)
pant.goto(-110,-190)
pant.end_fill()
Y=7
gb=Y*4
agua=Turtle(visible=False)
agua.pensize(4)
agua.penup()
agua.goto(110,-200)
agua.pendown()
agua.fillcolor(encendido)
agua.begin_fill()
agua.goto(110,-200+gb)
agua.penup()
agua.goto(-110,-200+gb)
agua.pendown()
agua.goto(-110,-200)
agua.goto(110,-200)
agua.end_fill()
update()
ts=getscreen().getcanvas()
tmpdir=tempfile.mkdtemp()
tmpfile=os.path.join(tmpdir,'tmp.svg')
canvasvg.saveall(tmpfile,ts)
name="image4.png"
with open(tmpfile) as svg_input, open(name, 'wb')as png_output:
cairosvg.svg2png(bytestring=svg_input.read(),write_to=png_output)
shutil.rmtree(tmpdir)

ModuleNotFoundError: No module named 'SessionState

I am trying to make use of the streamlit SessionState, when I import SessionState. I get the following error: ModuleNotFoundError: No module named 'SessionState'
when using he SessionState
Here is a snipnet of my code:
from multiprocessing import Process
import streamlit as st
import SessionState
import time
import os
import signal
st.sidebar.title("Controls")
start = st.sidebar.button("Start")
stop = st.sidebar.button("Stop")
state = SessionState.get(pid=None)
Has anyone encountered this and how did you fix it? There are no resources online
https://docs.streamlit.io/en/stable/changelog.html?highlight=SessionState#version-0-54-0
Seems like you have to download this gist and put it into your project in order to use SessionState

Cannot import class from module (circular reference issue?)

I've seen countless issues here on stack about this but still can't figure out why I cant get mine to work. I have a 2 .ipynb files and I'm looking to import a class from one file to the other as follows:
CV_Screening_Interface:
from joblib import dump, load
import sys
import pandas as pd
import os
import import_ipynb
import docx
import readDocx ***(This is another ipynb file)***
from docx import Document
import string
model = load('model.joblib')
class CV:
def __init__(self,university,major,masters,company,certification,GPA):
self.university = university
self.major = major
self.masters = masters
self.company = company
self.certification = certification
self.GPA = GPA
#And a bunch of other functions
Now in FirstProgram
from tkinter import *
from tkinter import filedialog
from docx import Document
import io
import import_ipynb
import CV_Screening_Interface
#Till here works fine
When I try to import class CV I get an import error
from CV_Screening_Interface import CV
OR
test = CV_Screening_Interface.CV()
ImportError: cannot import name 'CV' from 'CV_Screening_Interface' (CV_Screening_Interface.ipynb)
I checked PYTHONPATH, I have an empty init.py in the directory already. What's weird is that importing the module works, but importing the class in the module doesn't.
Note in CV_Screening_Interface CV class works perfectly fine so I don't think there is any issue with it specifically. Probably need a if name="main" inside it?
Ok so this solved my problems:
I created a new ipynb called ClassFile.ipynb and it only contains the Class CV without importing any packages
Then i converted ClassFile.ipynb to ClassFile.py and imported it to FirstProgram and it worked.

How to import "gleam" package in Python 3?

I'm tyring to import the "gleam" package in Python 3. I have installed the "gleam" package successfully, but still it showing error.
from wtforms import fields
from ggplot import *
from gleam import Page, panels
class ScatterInput(panels.Inputs):
title = fields.StringField(label="Title of plot:")
yvar = fields.SelectField(label="Y axis",
choices=[("beef", "Beef"),
("pork", "Pork")])
smoother = fields.BooleanField(label="Smoothing Curve")
class ScatterPlot(panels.Plot):
name = "Scatter"
def plot(self, inputs):
p = ggplot(meat, aes(x='date', y=inputs.yvar))
if inputs.smoother:
p = p + stat_smooth(color="blue")
p = p + geom_point() + ggtitle(inputs.title)
return p
class ScatterPage(Page):
input = ScatterInput()
output = ScatterPlot()
ScatterPage.run()
Error:
ModuleNotFoundError - Traceback (most> recent call last) in ()
----> 1 import gleam
C:\pythonNJ\lib\site-packages\gleam__init__.py in ()
5 import os
6 import json
----> 7 import urlparse
8 from collections import namedtuple
9
ModuleNotFoundError: No module named 'urlparse'
I looked for the solution and I found that urlparse has been moved to a new module in python 3, which can be imported as
from urllib.parse import urlparse
And I even imported it, but still when I trying to import "gleam" package it shows error of module "urlparse". Can you suggest me how to bypass it (bypassing import urlparse statement and importing gleam package in Python 3).
I know how to import the urlparse but I don't know how to import the gleam package.
You have two possiblities:
Modify source code yourself as you stated inside gleam package, but it could work incorrectly.
Fall back to version of python it works on - so 2.7 it seems, since the modification you mentioned was done with python 3.0 release. It's stated in docs here.
Just do this to get over it:
from:
import urlparser
to:
import urllib.parse

Import image in python

hello I am a beginner in python and I have problems executing my code .
how can i fix this error with python:
import cgitb
cgitb.enable()
print('Content-type: text/html\r\n')
print('\r\n')
import Image, ImageDraw
import sys
import math, random
from itertools import product
from ufarray import *
ModuleNotFoundError: No module named 'Image'
args = ("No module named 'Image'",)
msg = "No module named 'Image'"
name = 'Image'
path = None
with_traceback = <built-in method with_traceback of ModuleNotFoundError
Make sure you have installed Pillow (the supported, open-source version of the PIL Python Image Library) and then change your import to:
from PIL import Image, ImageDraw
That should get you farther along.
Try this:
from PIL import Image
or else you haven't installed it yet:
pip install pillow
I had a similar Problem, this post helped me: How to insert an image in python
What they basically use is:
import Image
myImage = Image.open("your_image_here");
myImage.show();
For more help I would need your full code. Even after the edit it is not quite clear to me what is your code, what is the error and what you are actually trying to do.

Categories