pinecone-io / pinecone-python-client

The Pinecone Python client
https://www.pinecone.io/docs
Apache License 2.0
274 stars 73 forks source link

[Bug] I can't create an exe using pinecone #200

Open ikrammert opened 10 months ago

ikrammert commented 10 months ago

Is this a new bug in the Pinecone Python client?

Current Behavior

I am trying to extract an exe from the code I wrote with Pinecone using pyinstaller. pyinstaller --onefile main.py -n pinecone.exe

Expected Behavior

I get this error while creating exe

185920 INFO: Fixing EXE headers
186784 INFO: Building EXE from EXE-00.toc completed successfully.
Generating spec file...Traceback (most recent call last):
  File "main.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "init.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "nodes\CreateIndex.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "pinecone\__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "pinecone\core\utils\constants.py", line 33, in <module>
  File "pinecone\core\utils\__init__.py", line 53, in get_environment
  File "pathlib.py", line 1134, in read_text
  File "pathlib.py", line 1119, in open
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\IKRAMM~1\\AppData\\Local\\Temp\\_MEI260042\\pinecone\\__environment__'
[25284] Failed to execute script 'main' due to unhandled exception!
2023/09/22 14:29:48 exit status 1

Steps To Reproduce

apiKey = "my_key" environment = "my"

pinecone.init(api_key=apiKey,environment=environment) a= pinecone.list_indexes() print(a) params={} a['name']= "helloworld" a['dimension'] = 8

pinecone.create_index(name="helloworld", dimension=8, metric="euclidean")

pinecone.create_index(**params) pinecone.describe_index("helloworld") a= pinecone.list_indexes() print(a)

2.  pyinstaller --onefile a.py -n test-pinecone.exe

### Relevant log output

_No response_

### Environment

```markdown
- OS: windows 11
- Python: 3.10.11
- pinecone: 2.2.4
- pyinstaller: 5.13.2

Additional Context

No response

daverigby commented 2 months ago

Pinecone client initialisation has been significantly refactored as of v3.0.0 - global state including various code executed during import pinecone has been moved into the Pinecone and Index objects.

As such, I would recommend re-testing this with the latest version of the SDK - while I cannot guarantee the issue you were seeing was fixed (and I don't have a Windows environment readily available to test with), a lot of the internals have changed and you might have more success with v3 and upwards.