import shapely.geometry throws AttributeError: function 'GEOSversion' not found - python

import shapely.geometry works fine in the interpreter but the code throws this error when running:
AttributeError: function 'GEOSversion' not found
Also tried
import geos
ImportError: No module named geos`
But Shapely used to run perfectly.
Have not found any post regarding this problem in SO. Any help is much appreciated. Thanks!
Shapely‑1.3.2.win‑amd64‑py2.7.exe installed from this link which is supposed to include GEOS dependencies.
Python 2.7 64bit Anaconda on Win7 64bit. Using Eclipse with PyDev
Traceback (most recent call last):
File "C:\...\file.py", line 3, in <module>
import shapely.geometry
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\site-packages\shapely\geometry\base.py", line 9, in <module>
from shapely.coords import CoordinateSequence
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\site-packages\shapely\geos.py", line 125, in <module>
geos_version_string, geos_version, geos_capi_version = _geos_version()
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\site- packages\shapely\geos.py", line 112, in _geos_version
GEOSversion = _lgeos.GEOSversion
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Users\AppData\Local\Continuum\Anaconda\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'GEOSversion' not found

Related

Tflite model m aker issue - undefined symbol table __scann_ops.os

Anyone know how to solve this python tensorflow issue?
Traceback (most recent call last):
File "lite_model_gen.py", line 6, in <module>
from tflite_model_maker.config import ExportFormat
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/__init__.py", line 51, in <module>
from tflite_model_maker import searcher
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tflite_model_maker/searcher/__init__.py", line 25, in <module>
from tensorflow_examples.lite.model_maker.core.task.searcher import ExportFormat
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/task/searcher.py", line 30, in <module>
from tensorflow_examples.lite.model_maker.core.utils import ondevice_scann_builder
File "/home/ubuntu/examples/tensorflow_examples/lite/model_maker/pip_package/src/tensorflow_examples/lite/model_maker/core/utils/ondevice_scann_builder.py", line 17, in <module>
from scann.proto import scann_pb2
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/__init__.py", line 2, in <module>
from scann.scann_ops.py import scann_ops
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/scann_ops/py/scann_ops.py", line 23, in <module>
_scann_ops_so = tf.load_op_library(
File "/home/ubuntu/bert_QA/env/lib/python3.8/site-packages/tensorflow/python/framework/load_library.py", line 54, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/ubuntu/bert_QA/env/lib/python3.8/site-packages/scann/scann_ops/cc/_scann_ops.so: undefined symbol: _ZN4absl12lts_2021032416numbers_internal9kHexTableE
It occurs when I attempt to use the tflite_model_maker library. Corrupted or outdated shared library file?
Okay, I discovered it could be fixed by simply installing scann using pip:
pip install scann

Numpy is Not a Generic Class

I am trying to learn Python and following along some modules. I am using Anaconda Powershell Prompt and using Python 3.7 from there. I am trying to follow along via the code below.
Everything works until I get to the line
from wrf import getvar
When I do that line I receive this
>>> from wrf import getvar
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Paul\anaconda3\lib\site-packages\wrf\__init__.py", line 6, in <module>
from . import api
File "C:\Users\Paul\anaconda3\lib\site-packages\wrf\api.py", line 1, in <module>
from .config import (xarray_enabled, disable_xarray, enable_xarray,
File "C:\Users\Paul\anaconda3\lib\site-packages\wrf\config.py", line 62, in <module>
_init_local()
File "C:\Users\Paul\anaconda3\lib\site-packages\wrf\config.py", line 52, in _init_local
_try_enable_xarray()
File "C:\Users\Paul\anaconda3\lib\site-packages\wrf\config.py", line 17, in _try_enable_xarray
from xarray import DataArray
File "C:\Users\Paul\anaconda3\lib\site-packages\xarray\__init__.py", line 1, in <module>
from . import testing, tutorial
File "C:\Users\Paul\anaconda3\lib\site-packages\xarray\testing.py", line 9, in <module>
from xarray.core import duck_array_ops, formatting, utils
File "C:\Users\Paul\anaconda3\lib\site-packages\xarray\core\duck_array_ops.py", line 26, in <module>
from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
File "C:\Users\Paul\anaconda3\lib\site-packages\xarray\core\npcompat.py", line 72, in <module>
_SupportsDType[np.dtype],
File "C:\Users\Paul\anaconda3\lib\typing.py", line 275, in inner
return func(*args, **kwds)
File "C:\Users\Paul\anaconda3\lib\typing.py", line 999, in __class_getitem__
_check_generic(cls, params, len(cls.__parameters__))
File "C:\Users\Paul\anaconda3\lib\typing.py", line 209, in _check_generic
raise TypeError(f"{cls} is not a generic class")
TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class
Looks like the last few lines return an error but as a beginner I have zero clue what this means.
This looks like a similar error to <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class when importing the plotly.express library - an incompatibility between wrf-python and numpy.
Try upgrading those libraries to the latest versions.

Checkov error: AttributeError: type object 'Lark' has no attribute '_load_from_dict

I'm having some issues running checkov, I'm not familiar with python libraries, anyone can give me some hints?
This is working fine in some machines but not in this one in particular...
Running in CentOS:
$ checkov --directory cdk.out
Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in <module>
from checkov.main import run
File "/usr/local/lib/python3.6/site-packages/checkov/main.py", line 22, in <module>
from checkov.terraform.plan_runner import Runner as tf_plan_runner
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/plan_runner.py", line 11, in <module>
from checkov.terraform.context_parsers.registry import parser_registry
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/__init__.py", line 1, in <module>
from checkov.terraform.context_parsers.parsers import *
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/parsers/provider_context_parser.py", line 1, in <module>
import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/__init__.py", line 5, in <module>
from .api import load, loads
File "/usr/local/lib/python3.6/site-packages/hcl2/api.py", line 4, in <module>
from hcl2.parser import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/parser.py", line 53, in <module>
hcl2 = Lark_StandAlone(transformer=DictTransformer())
File "/usr/local/lib/python3.6/site-packages/hcl2/lark_parser.py", line 8, in Lark_StandAlone
return Lark._load_from_dict(DATA, MEMO, **kwargs)
AttributeError: type object 'Lark' has no attribute '_load_from_dict'
After upgrading python from 3.6 to 3.8 and reinstalling checkov it worked just fine.

Can't import geopandas (Python 3.7 64 bit)

I'm trying to import geopandas in my script but I keep getting the following error:
Traceback (most recent call last):
File "C:/Users/USERNAME/Desktop/Scripts/Project1/folium_map/89. geographical chart 4.py", line 1, in <module>
import geopandas
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\geopandas\__init__.py", line 1, in <module>
from geopandas.geoseries import GeoSeries
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\geopandas\geoseries.py", line 12, in <module>
from geopandas.base import GeoPandasBase, _series_unary_op, _CoordinateIndexer
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\geopandas\base.py", line 14, in <module>
from rtree.core import RTreeError
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\rtree\__init__.py", line 1, in <module>
from .index import Rtree
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\rtree\index.py", line 5, in <module>
from . import core
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-packages\rtree\core.py", line 133, in <module>
rt.Error_GetLastErrorNum.restype = ctypes.c_int
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 369, in __getattr__
func = self.__getitem__(name)
File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 374, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Error_GetLastErrorNum' not found
My code looks just like this:
import geopandas
Has anyone else received this error before? And if so, how did they fix it? Thanks in advance.
EDIT 05/02/19:
Also I have GDAL 2.3.3 amd64 installed.

Error after "from new import instancemethod" when importing scipy.stats

I am getting an exception from scipy whenever I try to import the nltk package. The command and the error looks like this:
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/usr/local/lib/python2.7/dist-packages/nltk/collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/__init__.py", line 16, in <module>
from nltk.metrics.scores import (accuracy, precision, recall, f_measure,
File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/scores.py", line 16, in <module>
from scipy.stats.stats import betai
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 344, in <module>
from .stats import *
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/stats.py", line 176, in <module>
from . import distributions
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 10, in <module>
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
File "/usr/local/lib/python2.7/dist-packages/scipy/stats/_distn_infrastructure.py", line 43, in <module>
from new import instancemethod
File "new.py", line 107
return copy.deepcopy(self)
^
IndentationError: expected an indented block
I executed this command in a terminal (ubuntu 16.04 LTS system). I did not find anything about this error and the indentation doesn't look wrong.
The SyntaxError is in your file new.py (I guess it's in your current working directory). Try to switch to a directory where no new.py file is present (or move the new.py file in another directory), then the internal scipy import should work without problems.
On the other hand you can just upgrade to scipy 0.19.x. They removed the import there and it should work without problems.
Note that it's always a bad idea to name python files like builtin-modules! That's a common source for exceptions or unexpected behaviour.

Categories