Search code examples
pythoninstallationerror-handlingflet

How do I import Flet getting errors


I've been trying to install flet and use it for the past 2 hours and no matter what i try it keeps giving an error, even when I manually install each module "not found" it gives some attribution error from one of the flet files. I updated Python to 3.11 because I heard somewhere that flet doesn't work with 3.9 but it's still not working. How do you properly install flet? What could be my error? I have flet in the directory my program is in and python is installed in another directory (rhe default program files directory) but I'm not sure if that is what's affecting it as my python program runs fine without python in it. Any solutions?

modules not found: H2, click, socksio, bunch of others(shouldn't these modules be in flet, if not why do i have to install a million other modules just to use flet when I've seen other people run the install flet command and jump right into using it?)

-I ran the command pip install flet (it installed what seemed to be the latest version)

  • i updated python to 3.11 and tried changing the environment on visual studio to it
  • my import statement: import flet as ft

I expect for it to import flet( I just wanna see if the program runs after i import flet, I haven't started the process of using flet yet because it keeps giving me this error)


Solution

  • Hmm usually when you encounter uninstalled/outdated modules after running pip install it means you are running pip install and running the script itself using different python environments.

    Many times our terminal/cmd from which we install our modules with pip use a specific python that you did not plan to use and run the script with.

    It seems like it might be your case as you mentioned that you have both 3.9 3.11 installed.

    There are a couple of ways to deal with such problem, or at least make sure it isn't your case so we can understand better your problem.

    Ways to solve different python environments complications:

    • Install flet within the package installer of Pycharm (if you use pycharm), head to File -> Setting -> Project -> Python Interpreter, choose your desired python environment, press the + icon and search for flet. This way you easily control the python you are installing to.

    • Remove all unwanted python environments that you don't plan to use. That will definitely make life easier.

    • Check the Python interpreter configuration when you run your script. On the top right of Pycharm you will see a down arrow and in the dropdown find Edit Configurations..., find the configuration that is used for your script and under Python Interpreter try to change it to a different one that might have flet installed in it already.

    Also try using pip install -U flet to make sure you install all latest.