ImportError: cannot import name 'ratio' from 'Levenshtein' (unknown location) - levenshtein-distance

When I try import fuzzymatcher I get the error:
ImportError: cannot import name 'ratio' from 'Levenshtein' (unknown location)

Add the line #include <Python.h> to first line of the file _levenshtein.c inside of the Levenshtein folder.
Then in fuzzywuzzy folder, replace from .StringMatcher import StringMatcher as SequenceMatcher with from Levenshtein import *.

Related

error 'import string_types ValueError: Attempted relative import in non-package'

Using cmd on windows 10 to run Python 2.7.16. When I run a .py file which imports scipy.py it comes up with the error:
"File "C:\Python27\scipy.py", line 18, in
from .python import string_types
ValueError: Attempted relative import in non-package"
As string_types should already be included in python, I don't understand why this error is happening and cant seem to get passed it. Does anyone know how to fix this?
you tried,
>>> from . import MyModule #MyModule.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Attempted relative import in non-package
>>>
here . mean your current path
try,
from MyModule import *
now you can use string_types
or
import MyModule as m
m.string_types

ImportError: No module named dtracedata

I m using this line in my python code
from test.dtracedata import instances
in eclipse.
Python Version-2.7.15
Then it will show this error
importerror: no module named dtracedata

Autodoc Cython/NumPy with Sphinx

I have some trouble to document my Cython (python 2.7) module with Sphinx (1.7).
I set the Cython directive embedsignature to True, and I also mock numpy in my conf.py file. However, if I run sphinx-build -b html source build I get the following TypeError:
WARNING: autodoc: failed to import module u'isolver'; the following exception was raised:
Traceback (most recent call last):
File "C:\Users\xxx\Anaconda2\lib\site-packages\sphinx\ext\autodoc\importer.py", line 140, in import_module
__import__(modname)
File "c:\users\xxx\dropbox\github\isolver\isolver\__init__.py", line 1, in <module>
import core
File "c:\users\xxx\dropbox\github\isolver\isolver\core\__init__.py", line 1, in <module>
import c_trf
File "__init__.pxd", line 155, in init isolver.core.c_trf
TypeError: numpy.dtype is not a type object
The weird thing is I do not have a *.pxd file and line 155 in c_trf.pyx file is empty.
Perhaps the secret of this error lies in the way how I declared the numpy data types?
cimport numpy as np
import numpy as np
DTYPE_int = np.int64
ctypedef np.int64_t DTYPE_int_t
DTYPE_float = np.float64
ctypedef np.float64_t DTYPE_float_t
Or maybe the declarations of some functions with cdef np.ndarray fun(x):... are wrong?

Code error- Python 2.7

I pip install requests module and bs4 module. In C drive i can see the installed modules:
and this is the sys.path of the added modules:
When i check all sys.path with:
import sys
for i in sys.path:
print i
UPTADE
i get this list:
C:\Python27new\Lib\site-packages
C:\Program Files (x86)\ArcGIS\Desktop10.3\bin
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolBox\Scripts
But when i try to import requests and bs4 modules i get an error:
>>> import requests
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import requests
ImportError: No module named requests
and the same for bs4 module:
ImportError: No module named bs4
If the picture is a listing of C:\Python27new\Lib\site-packages then you want that in your path, not C:\Python27new\Lib\site-packages\requests.

Python Module Import from another directory

I'm getting a module import error.
My main file is /home/mininet/pythonscripts/import.py:
and my module file is /home/mininet/test/hello.py:
The error I'm getting is:
File "import.py", line 7, in <module> from test.hello import sqr,print_func
ImportError: No module named hello
i also added the __init__.py file in the module search path..please help!!
In order to import /home/mininet/test/hello.py as test.hello, you have to fulfill two requirements:
/home/mininet/test/__init__.py must exist to mark test as a package.
/home/mininet must be on sys.path so that Python finds test/hello.py when looking for test.hello.
Note that having /home/mininet/test on sys.path lets you import hello, but not import test.hello.