Python Forum

Full Version: get Python working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I drowned my laptop with a glass of water! Everything dead!

So I bought a new laptop. It is taking a while to get it set up.

I installed pip, then I wanted to install fitz. There was something wrong with the path variable. Fixed that, $PATH is now:

Quote:pedro@pedro-MSI:~$ echo $PATH
/home/pedro/.local/bin:/home/pedro/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
So I tried pip again:

Quote:pedro@pedro-MSI:~$ pip3 install fitz
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: fitz in ./.local/lib/python3.10/site-packages (0.0.1.dev2)
Requirement already satisfied: pandas in ./.local/lib/python3.10/site-packages (from fitz) (2.2.2)
Requirement already satisfied: numpy in ./.local/lib/python3.10/site-packages (from fitz) (2.0.1)
Requirement already satisfied: nipype in ./.local/lib/python3.10/site-packages (from fitz) (1.8.6)
Requirement already satisfied: configparser in ./.local/lib/python3.10/site-packages (from fitz) (7.0.0)
Requirement already satisfied: nibabel in ./.local/lib/python3.10/site-packages (from fitz) (5.2.1)
Requirement already satisfied: scipy in ./.local/lib/python3.10/site-packages (from fitz) (1.14.0)
Requirement already satisfied: configobj in ./.local/lib/python3.10/site-packages (from fitz) (5.0.8)
Requirement already satisfied: pyxnat in ./.local/lib/python3.10/site-packages (from fitz) (1.6.2)
Requirement already satisfied: httplib2 in /usr/lib/python3/dist-packages (from fitz) (0.20.2)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from configobj->fitz) (1.16.0)
Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in ./.local/lib/python3.10/site-packages (from httplib2->fitz) (3.1.2)
Requirement already satisfied: packaging>=17 in ./.local/lib/python3.10/site-packages (from nibabel->fitz) (24.1)
Requirement already satisfied: click>=6.6.0 in /usr/lib/python3/dist-packages (from nipype->fitz) (8.0.3)
Requirement already satisfied: prov>=1.5.2 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (2.0.1)
Requirement already satisfied: networkx>=2.0 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (3.3)
Requirement already satisfied: etelemetry>=0.2.0 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (0.3.1)
Requirement already satisfied: filelock>=3.0.0 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (3.15.4)
Requirement already satisfied: rdflib>=5.0.0 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (6.3.2)
Requirement already satisfied: looseversion in ./.local/lib/python3.10/site-packages (from nipype->fitz) (1.3.0)
Requirement already satisfied: simplejson>=3.8.0 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (3.19.2)
Requirement already satisfied: traits!=5.0,<6.4,>=4.6 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (6.3.2)
Requirement already satisfied: python-dateutil>=2.2 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (2.9.0.post0)
Requirement already satisfied: pydot>=1.2.3 in ./.local/lib/python3.10/site-packages (from nipype->fitz) (3.0.1)
Requirement already satisfied: pytz>=2020.1 in /usr/lib/python3/dist-packages (from pandas->fitz) (2022.1)
Requirement already satisfied: tzdata>=2022.7 in ./.local/lib/python3.10/site-packages (from pandas->fitz) (2024.1)
Requirement already satisfied: lxml>=4.3 in ./.local/lib/python3.10/site-packages (from pyxnat->fitz) (5.2.2)
Requirement already satisfied: pathlib>=1.0 in ./.local/lib/python3.10/site-packages (from pyxnat->fitz) (1.0.1)
Requirement already satisfied: requests>=2.20 in /usr/lib/python3/dist-packages (from pyxnat->fitz) (2.25.1)
Requirement already satisfied: ci-info>=0.2 in ./.local/lib/python3.10/site-packages (from etelemetry>=0.2.0->nipype->fitz) (0.3.0)
Requirement already satisfied: isodate<0.7.0,>=0.6.0 in ./.local/lib/python3.10/site-packages (from rdflib>=5.0.0->nipype->fitz) (0.6.1

But I am getting errors:

Quote:import fitz
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "<pyshell#0>", line 1, in <module>
File "/home/pedro/.local/lib/python3.10/site-packages/fitz/__init__.py", line 1, in <module>
from frontend import *
ModuleNotFoundError: No module named 'frontend'

So I imported frontend. Now I get:

Quote:import fitz
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "<pyshell#1>", line 1, in <module>
File "/home/pedro/.local/lib/python3.10/site-packages/fitz/__init__.py", line 1, in <module>
from frontend import *
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/__init__.py", line 1, in <module>
from .events import *
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/events/__init__.py", line 1, in <module>
from .clipboard import *
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/events/clipboard.py", line 2, in <module>
from ..dom import Event
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/dom.py", line 439, in <module>
from . import dispatcher
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/dispatcher.py", line 15, in <module>
from . import config, server
File "/home/pedro/.local/lib/python3.10/site-packages/frontend/server.py", line 24, in <module>
app.mount(config.STATIC_ROUTE, StaticFiles(directory=config.STATIC_DIRECTORY), name=config.STATIC_NAME)
File "/home/pedro/.local/lib/python3.10/site-packages/starlette/staticfiles.py", line 60, in __init__
raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory 'static/' does not exist

I have run out of ideas.

What should I do?

I can, for example, import os
I think you installed this fitz module. Not sure this is the fitz module you really want
https://github.com/kastman/fitz Wrote:This repo and python library are not connected with PyMuPDF or it's fitz module
Quote:Note on the Name fitz
Old versions of PyMuPDF had their Python import name as fitz.
Newer versions use pymupdf instead, and offer fitz as a fallback so that old code will still work.
From PyMuPDF 1.24.3 --> and newer version there is no longer any need to use import fitz.
So is fitz is just the the old name,and now is just the same as PyMuPDF.
The name fitz is still thee when install PyMuPDF,but now only import pymupdf is needed.
>>> import pymupdf
>>> import fitz 
>>>
>>> pymupdf.version
('1.24.9', '1.24.8', '20240724000001')
>>> fitz.version
('1.24.9', '1.24.8', '20240724000001')
Thanks!

Worked fine with

Quote:(GP_env) pedro@pedro-MSI:~/Python_Virtual_Environments$ pip3 install pymupdf

Now I can import fitz in Idle!

I just had so much stuff to set up after drowning my old laptop! I get confused!