0

I installed package tethne-0.8 (successfully on Windows 10, which worked well (that is, I could import it). Then, I started fiddling around a little bit, uninstalling the package, installing an older version, uninstalling the older version, and finally re-installing tethne-0.8. I really regret doing so (I should have known!), because now, importing tethne throws the following error:

File "C:\Python27\lib\site-packages\tethne\classes\feature.py", line 8, in <module>
from tethne.utilities import _iterable
ImportError: cannot import name _iterable

Tethne-0.8 is said to have installed successfully and I've checked all dependencies, which are also okay. I've also looked into the feature.py file:

"""
Classes in this module provide structures for additional data about
:class:`.Paper`\s.
"""

from collections import Counter, defaultdict

from tethne.utilities import _iterable
try:    # Might as well use numpy if it is available.
    import numpy as np
    argsort = lambda l: list(np.argsort(l))
except ImportError:
    from tethne.utilities import argsort

...and the utilities.py file:

def _iterable(o):
    if hasattr(o, '__iter__'):
        return o
    else:
        return [o]

I have obviously tried googling the issue. It's driving me crazy and really hope someone has a tip!

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
NynkeLys
  • 95
  • 2
  • 11
  • check tethne.utilities for _iterable ? – matisetorm Feb 21 '18 at 12:59
  • I've edited my post. I'm sorry, I'm quite new to all this and really don't know how to go about it. – NynkeLys Feb 21 '18 at 13:03
  • No worries at all. just was trying to dig :) – matisetorm Feb 21 '18 at 13:04
  • :-) Any idea what the issue might be? – NynkeLys Feb 21 '18 at 13:09
  • I'm a bit stumped. If you are using a `virtualenv` or `conda`, I might create a new environment with a fresh install. If not, I might start using one of the two aforementioned environment managers so you have more control over your environment. -- alternatively, if you are using python3, you could use `pip-autoremove somepackage -y` to remove the package plus dependencies and then re install the package you want. That may give you a fresh install – matisetorm Feb 21 '18 at 13:19
  • `import tethne`, `print(tethne)`, `from tethne import utilities`, `print(utilities)`, to make sure that the modules that you are importing are the ones you *think* that you are importing. – CristiFati Feb 21 '18 at 13:30
  • @CristiFati I can't run any of those commands, they all give me the same ImportError message :-( – NynkeLys Feb 21 '18 at 13:34
  • @matisetorm I use Python 2.7 (on purpose) without an environment manager and have already tried uninstalling and re-installing the package, using pip uninstall tethne and pip install -U tethne (and tried pip install tethne as well) – NynkeLys Feb 21 '18 at 13:35
  • No, they, don't, it's your original line that does. Place them before `import _iterable`. – CristiFati Feb 21 '18 at 13:35
  • It says: "ImportError: cannot import name utilities" now @CristiFati – NynkeLys Feb 21 '18 at 14:10
  • Then, replace the last 2 statements that I mentioned by `print(tethne.utilities)`. – CristiFati Feb 21 '18 at 14:11
  • Damn it: "AttributeError: 'module' object has no attribute 'utilities'". Sorry, I can't move to chat yet, as my reputation is not high enough. Thanks a lot for your help @CristiFati – NynkeLys Feb 21 '18 at 14:15
  • Does this tell you anything, @CristiFati? http://diging.github.io/tethne/tethne.html#module-tethne.utilities – NynkeLys Feb 21 '18 at 14:38
  • https://github.com/diging/tethne/blob/python/tethne/utilities.py#L108 does have that. Most likely the version that you have doesn't. Check your file. – CristiFati Feb 21 '18 at 15:51
  • 2
    Please do not add the solution to your question. If you found a solution that worked best for you, then you can accept it below or answer your own question. This site encourages multiple solutions from other users, as the one that worked best for you may not work the best for someone else. – K.Dᴀᴠɪs Feb 21 '18 at 15:56
  • @CristiFati my file had that as well, so that was not it. I found a solution (see my edit) THOUGH I'm not entirely sure why it now works! – NynkeLys Feb 21 '18 at 15:57
  • @K.Davis OK! Didn't know! I'll change it :-) – NynkeLys Feb 21 '18 at 15:57

1 Answers1

0

I seem to have found one working solution: I added the following two lines of code in the feature.py file, before importing _iterable. Now, I can import tethne successfully.

from collections import Counter, defaultdict
from tethne.utilities import mean
NynkeLys
  • 95
  • 2
  • 11