How to fix this error : simple run error with the library faster_than_requests

103 Views Asked by At

here is my simple code with the faster_than_requests library :

import faster_than_requests as requests

t = requests.get("http://httpbin.org/get")
print(t)

As you can see the code is not the problem but i am getting that as an error in my console :

PS C:\Users\Admin\Desktop\Projects\Outlook> & C:/Users/Admin/AppData/Local/Programs/Python/Python312/python.exe c:/Users/Admin/Desktop/Projects/Outlook/test.py
Traceback (most recent call last):
  File "c:\Users\Admin\Desktop\Projects\Outlook\test.py", line 1, in <module>
    import faster_than_requests as requests
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\faster_than_requests\__init__.py", line 7, in <module>
    from . faster_than_requests import *
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1262, in _find_spec
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\nimporter.py", line 1273, in find_spec
    return Nimporter.import_nim_code(fullname, path, library=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\nimporter.py", line 948, in import_nim_code
    NimCompiler.compile_nim_code(
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\nimporter.py", line 709, in compile_nim_code
    cls.check_compile_errors(errors, library, nim_args, output, tmp_cwd, warnings)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\nimporter.py", line 496, in check_compile_errors      
    raise NimCompileException(errors[0])
nimporter.NimCompileException: faster_than_requests.nim(2, 18) Error: cannot open file: db_sqlite

I don't know what is wrong, i am not good with nim or whatsoever..

I tried searching online for an answer but no one was talking about that issue so i came here.

1

There are 1 best solutions below

0
xbello On

This is out of reach for you. Recent (2.0.0) Nim update removed some libraries from the std to their own package. In this case, db_sqlite has been moved to db_connector, but faster_than_requests package in Pypi still does the old import:

faster_than_requests.nim, line 2:

import asyncdispatch, db_sqlite...

When it should be

import db_connector/db_sqlite

The library has to be updated by his author to be compatible with Nim > 2.0, because if this code is failing, I'm sure there are some other incompatibilities that you cannot solve just by switching an import.

But you can still do it! As this is a recent thing, you can still use Nim 1.6.18, the last version before 2.0.0. With choosenim you can have multiple Nim versions in your computer (disclaimer: I never used it on Windows, only in Linux). Once choosenim is installed in your machine, do this:

choosenim 1.6.18

And then try to run your python script.

Optionally, open an issue in the github repo for the faster_than_requests package.

Good luck!