openai / chatgpt-retrieval-plugin

The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.
MIT License
20.98k stars 3.68k forks source link

etree import error when using poetry run start with Python 3.10.0 #183

Open Mozartismee opened 1 year ago

Mozartismee commented 1 year ago

Hello,

I am encountering a problem with the import of "etree" failing repeatedly when using "poetry run start" (although "lxml" can be imported). I am using python version 3.10.0 and have already used "poetry install", and I have also searched for any missing dependencies, but the issue still persists. However, if I use python version 3.9.16, "from lxml import etree" can be imported correctly. I think this is worth mentioning. I would appreciate it if you could help me solve this issue. Here is some information regarding my use:

1. poetry env info:

Virtualenv Python: 3.10.0 Implementation: CPython Path: /Users/[myusername]/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10 Executable: /Users/[myusername]//Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/bin/python Valid: True

System Platform: darwin OS: posix Python: 3.10.0 Path: /Library/Frameworks/Python.framework/Versions/3.10 Executable: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10

2. poetry install:

Installing dependencies from lock file

No dependencies to install or update

Installing the current project: chatgpt-retrieval-plugin (0.1.0)

3. poetry run start :

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/Users/vernunft/chatgpt-retrieval-plugin/server/main.py", line 16, in from datastore.factory import get_datastore File "/Users/vernunft/chatgpt-retrieval-plugin/datastore/factory.py", line 1, in from datastore.datastore import DataStore File "/Users/vernunft/chatgpt-retrieval-plugin/datastore/datastore.py", line 13, in from services.chunks import get_document_chunks File "/Users/vernunft/chatgpt-retrieval-plugin/services/chunks.py", line 10, in tokenizer = tiktoken.get_encoding( File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/tiktoken/registry.py", line 56, in get_encoding _find_constructors() File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/tiktoken/registry.py", line 32, in _find_constructors mod = importlib.import_module(mod_name) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/tiktoken_ext/openai_public.py", line 1, in from tiktoken.load import data_gym_to_mergeable_bpe_ranks, load_tiktoken_bpe File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/tiktoken/load.py", line 10, in import blobfile File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/blobfile/init.py", line 6, in from blobfile._ops import ( File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/blobfile/_ops.py", line 27, in from blobfile._common import DirEntry, Stat File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/blobfile/_common.py", line 27, in from blobfile import _xml as xml File "/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/blobfile/_xml.py", line 6, in from lxml import etree ImportError: dlopen(/Users/vernunft/Library/Caches/pypoetry/virtualenvs/chatgpt-retrieval-plugin-Uefjp8tE-py3.10/lib/python3.10/site-packages/lxml/etree.cpython-310-darwin.so, 0x0002): symbol not found in f

4. poetry show:

poetry show aiohttp 3.8.4 Async http client/server framework (asyncio) aiosignal 1.3.1 aiosignal: a list of registered asynchron... anyio 3.6.2 High level compatibility layer for multip... arrow 1.2.3 Better dates & times for Python async-timeout 4.0.2 Timeout context manager for asyncio programs attrs 22.2.0 Classes Without Boilerplate authlib 1.2.0 The ultimate Python library in building O... blobfile 2.0.1 Read GCS, ABS and local paths with the sa... certifi 2022.12.7 Python package for providing Mozilla's CA... cffi 1.15.1 Foreign Function Interface for Python cal... charset-normalizer 3.1.0 The Real First Universal Charset Detector... click 8.1.3 Composable command line interface toolkit coverage 7.2.3 Code coverage measurement for Python cryptography 40.0.1 cryptography is a package which provides ... dataclasses-json 0.5.7 Easily serialize dataclasses to and from ... decorator 5.1.1 Decorators for Humans dnspython 2.3.0 DNS toolkit docx2txt 0.8 A pure python-based utility to extract te... exceptiongroup 1.1.1 Backport of PEP 654 (exception groups) fastapi 0.92.0 FastAPI framework, high performance, easy... filelock 3.11.0 A platform independent file lock. frozenlist 1.3.3 A list-like structure which implements co... grpcio 1.47.5 HTTP/2-based RPC framework grpcio-tools 1.47.5 Protobuf code generator for gRPC h11 0.14.0 A pure-Python, bring-your-own-I/O impleme... h2 4.1.0 HTTP/2 State-Machine based protocol imple... hpack 4.0.0 Pure-Python HPACK header compression httpcore 0.16.3 A minimal low-level HTTP client. httpx 0.23.3 The next generation HTTP client. hyperframe 6.0.1 HTTP/2 framing layer for Python idna 3.4 Internationalized Domain Names in Applica... iniconfig 2.0.0 brain-dead simple config-ini parsing langchain 0.0.133 Building applications with LLMs through c... llama-index 0.5.4 Interface between LLMs and your data. loguru 0.6.0 Python logging made (stupidly) simple lxml 4.9.2 Powerful and Pythonic XML processing libr... marshmallow 3.19.0 A lightweight library for converting comp... marshmallow-enum 1.5.1 Enum field for Marshmallow mmh3 3.0.0 Python wrapper for MurmurHash (MurmurHash... multidict 6.0.4 multidict implementation mypy-extensions 1.0.0 Type system extensions for programs check... numpy 1.24.2 Fundamental package for array computing i... openai 0.27.4 Python client library for the OpenAI API openapi-schema-pydantic 1.2.4 OpenAPI (v3) specification schema as pyda... packaging 23.0 Core utilities for Python packages pandas 2.0.0 Powerful data structures for data analysi... pillow 9.5.0 Python Imaging Library (Fork) pinecone-client 2.2.1 Pinecone client and SDK pluggy 1.0.0 plugin and hook calling mechanisms for py... protobuf 3.20.3 Protocol Buffers pycparser 2.21 C parser in Python pycryptodomex 3.17 Cryptographic library for Python pydantic 1.10.7 Data validation and settings management u... pymilvus 2.2.4 Python Sdk for Milvus pypdf2 3.0.1 A pure-python PDF library capable of spli... pytest 7.2.2 pytest: simple powerful testing with Python pytest-asyncio 0.20.3 Pytest support for asyncio pytest-cov 4.0.0 Pytest plugin for measuring coverage. python-dateutil 2.8.2 Extensions to the standard Python datetim... python-dotenv 0.21.1 Read key-value pairs from a .env file and... python-multipart 0.0.6 A streaming multipart parser for Python python-pptx 0.6.21 Generate and manipulate Open XML PowerPoi... pytz 2023.3 World timezone definitions, modern and hi... pyyaml 6.0 YAML parser and emitter for Python qdrant-client 1.1.1 Client library for the Qdrant vector sear... redis 4.5.1 Python client for Redis database and key-... regex 2023.3.23 Alternative regular expression module, to... requests 2.28.2 Python HTTP for Humans. rfc3986 1.5.0 Validating URI References per RFC 3986 setuptools 67.6.1 Easily download, build, install, upgrade,... six 1.16.0 Python 2 and 3 compatibility utilities sniffio 1.3.0 Sniff out which async library your code i... sqlalchemy 1.4.47 Database Abstraction Library starlette 0.25.0 The little ASGI library that shines. tenacity 8.2.2 Retry code until it succeeds tiktoken 0.2.0
tomli 2.0.1 A lil' TOML parser tqdm 4.65.0 Fast, Extensible Progress Meter typing-extensions 4.5.0 Backported and Experimental Type Hints fo... typing-inspect 0.8.0 Runtime inspection utilities for typing m... tzdata 2023.3 Provider of IANA time zone data ujson 5.4.0 Ultra fast JSON encoder and decoder for P... urllib3 1.26.15 HTTP library with thread-safe connection ... uvicorn 0.20.0 The lightning-fast ASGI server. validators 0.19.0 Python Data Validation for Humans™. weaviate-client 3.15.4 A python native weaviate client xlsxwriter 3.0.9 A Python module for creating Excel XLSX f... yarl 1.8.2 Yet another URL library

Mozartismee commented 1 year ago

To resolve this issue, I installed the dependencies libxslt and libxml2 using brew, and then installed lxml globally instead of in a virtual environment. This solution worked for me, and I hope it can also help others who are facing import errors with etree or any other dependency issues with lxml. Be sure to check your Python version and install the latest version of lxml.