inspirehep / magpie

Deep neural network framework for multi-label text classification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError while importing Magpie.

ArvindSoma opened this issue · comments

When i import magpie, I'm getting the following error:

`from magpie import Magpie

Using TensorFlow backend.
Traceback (most recent call last):
File "", line 1, in
File "/home/arvindsoma/Projects/magpie/magpie/init.py", line 1, in
from .main import Magpie
File "/home/arvindsoma/Projects/magpie/magpie/main.py", line 12, in
from magpie.base.word2vec import train_word2vec, fit_scaler
File "/home/arvindsoma/Projects/magpie/magpie/base/word2vec.py", line 7, in
from gensim.models import Word2Vec
File "/home/arvindsoma/classification/lib/python3.5/site-packages/gensim/init.py", line 6, in
from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
File "/home/arvindsoma/classification/lib/python3.5/site-packages/gensim/parsing/init.py", line 7, in
from .preprocessing import *
File "/home/arvindsoma/classification/lib/python3.5/site-packages/gensim/parsing/preprocessing.py", line 10, in
from gensim import utils
File "/home/arvindsoma/classification/lib/python3.5/site-packages/gensim/utils.py", line 50, in
from smart_open import smart_open
File "/home/arvindsoma/classification/lib/python3.5/site-packages/smart_open/init.py", line 1, in
from .smart_open_lib import *
File "/home/arvindsoma/classification/lib/python3.5/site-packages/smart_open/smart_open_lib.py", line 45, in
from boto.compat import BytesIO, urlsplit, six
File "/usr/lib/python3/dist-packages/boto/init.py", line 1216, in
boto.plugin.load_plugins(config)
File "/usr/lib/python3/dist-packages/boto/plugin.py", line 92, in load_plugins
for file in glob.glob(os.path.join(directory, '*.py')):
File "/home/arvindsoma/classification/lib/python3.5/posixpath.py", line 89, in join
genericpath._check_arg_types('join', a, *p)
File "/home/arvindsoma/classification/lib/python3.5/genericpath.py", line 143, in _check_arg_types
(funcname, s.class.name)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'
`

The value you are passing is null (None in Python). Just convert it to string (even an empty string will do)

Thanks for the reply! I'm getting this error while importing the library, without passing any variables. I set up all the libraries on the server(with Tensorflow=1.8) and I'm getting this error, while it's working on my personal system(TF=1.4). I'm not sure if i should edit the existing library files that are working well with my other projects.

It seems the problem is in os.path.join() - maybe there is something with your server's directory structure? (especially since you mention this is only happening on your server)

Well, I tried two things. First I assumed that its a problem with the libraries, so I made a requirements.txt file from my local env(Python 3.5) and then installed it on the server. This didn't work out!

Second, I tried creating a virtual environment using Python 2.7 and its running now. It seems that this problem is with Python 3.5+ and gensim word2vec or smart_open.

yeah, it seems like a gensim issue. You can also look at their forum for answers, but usually creating a local virtualenv is the best solution. It should work both for Python 2 and 3.

Thanks for your reply! Yes it seems more likely to be a gensim issue now. I used Python3.5 env on the server with virtualenv from the begining.
Now I had to port my project to Python 2.7 virtualenv on the server and its working well now.