While importing rasterio in QGIS is showing Exception: std::bad_alloc

Qgis Screenshot

When I re-import rasterio afterwards it shows error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 63, in runsource
    code = self.compile(source, filename, symbol)
  File "/usr/lib/python3.8/codeop.py", line 178, in __call__
    return _maybe_compile(self.compiler, source, filename, symbol)
  File "/usr/lib/python3.8/codeop.py", line 106, in _maybe_compile
    raise err1
  File "/usr/lib/python3.8/codeop.py", line 93, in _maybe_compile
    code1 = compiler(source + "\n", filename, symbol)
  File "/usr/lib/python3.8/codeop.py", line 143, in __call__
    codeob = compile(source, filename, symbol, self.flags, 1)
  File "<input>", line 1
    import rasterio
SyntaxError: multiple statements found while compiling a single statement

Python: 3.8.10
rasterio: 1.2.10
OS: Ubuntu 20.04 LTS . I installed QGIS by apt, and rasterio by pip.

  • i tried uninstalling rasterio and reinstalling, it does'nt helped. Nov 22 '21 at 8:47
  • How exactly did you install, using pip install rasterio or pip3 install rasterio or python3 -m pip install rasterio? Nov 22 '21 at 9:44
  • Initially i reinstalled by pip install rasterio but now i also tried sudo apt install python3-rasterio it also didn't worked. Nov 23 '21 at 8:17
  • @KadirŞahbaz any update? Nov 24 '21 at 11:09
  • Unfortunately no. Do you get the same error when using the python in terminal? Nov 24 '21 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.