Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on import llstring #1

Open
mehaase opened this issue Jul 25, 2016 · 1 comment
Open

Error on import llstring #1

mehaase opened this issue Jul 25, 2016 · 1 comment

Comments

@mehaase
Copy link

mehaase commented Jul 25, 2016

Hey Charlie, this is Mark from the HG team. I installed LLString by cloning the repo and the running pip install LLString/llstring, but I get a problem when I try to import it. This is not a problem if I put the package directly into my python path (instead of using pip), but I thought you might want to know anyway.

(venv) temp $ python
Python 3.5.1 (default, Apr 26 2016, 15:20:12)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import llstring
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mhaase/Downloads/temp/venv/lib/python3.5/site-packages/llstring/__init__.py", line 13, in <module>
    import matching, training, utilities
ImportError: No module named 'matching'

The error can be avoided (and the affected code can be simplified) with this patch:

diff --git a/llstring/llstring/__init__.py b/llstring/llstring/__init__.py
index 74a0009..6926814 100644
--- a/llstring/llstring/__init__.py
+++ b/llstring/llstring/__init__.py
@@ -5,8 +5,6 @@ Jaro-Winkler Similarity and Soft TF-IDF Similarity) as well
 as provides a variety of basic string processing/normalization
 tools.
 """
-from pkgutil import extend_path as __extend_path
-__path__ = __extend_path(__path__, __name__)
 __all__ = ['matching','training','utilities']
-import matching, training, utilities
+from . import matching, training, utilities

Let me know what you think!

@charliedagli
Copy link

Hi Mark,

Thank you so much for this note; I apologize for such a late reply (I don't
check this account often enough)!! My python packaging game is a bit weak
when it comes to getting the init.py's right; this is a great tip! I
will fold this change in...

Thanks again,
Charlie

On Mon, Jul 25, 2016 at 2:10 PM, Mark E. Haase notifications@github.com
wrote:

Hey Charlie, this is Mark from the HG team. I installed LLString by
cloning the repo and the running pip install LLString/llstring, but I get
a problem when I try to import it. This is not a problem if I put the
package directly into my python path (instead of using pip), but I
thought you might want to know anyway.

(venv) temp $ python
Python 3.5.1 (default, Apr 26 2016, 15:20:12)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import llstring
Traceback (most recent call last):
File "", line 1, in
File "/Users/mhaase/Downloads/temp/venv/lib/python3.5/site-packages/llstring/init.py", line 13, in
import matching, training, utilities
ImportError: No module named 'matching'

The error can be avoided (and the affected code can be simplified) with
this patch:

diff --git a/llstring/llstring/init.py b/llstring/llstring/init.py
index 74a0009..6926814 100644
--- a/llstring/llstring/init.py
+++ b/llstring/llstring/init.py
@@ -5,8 +5,6 @@ Jaro-Winkler Similarity and Soft TF-IDF Similarity) as well
as provides a variety of basic string processing/normalization
tools.
"""
-from pkgutil import extend_path as extend_path
-__path
= extend_path(__path, name)
all = ['matching','training','utilities']
-import matching, training, utilities
+from . import matching, training, utilities

Let me know what you think!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1, or mute the thread
https://github.com/notifications/unsubscribe-auth/AGRqBfboLXaASxK-C3KQGobdNzSNtS2wks5qZPv5gaJpZM4JUZIs
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants