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

No module named 'mpglue.classification._moving_window' #6

Open
takaakimasaki opened this issue Oct 24, 2018 · 12 comments
Open

No module named 'mpglue.classification._moving_window' #6

takaakimasaki opened this issue Oct 24, 2018 · 12 comments

Comments

@takaakimasaki
Copy link

I get an error message saying "No module named 'mpglue.classification._moving_window'" when I run "import mpglue import moving_window." I am running it on my Mac (MacOS High Sierra). Any advice you could give on solving this issue would be appreciated.

@jgrss
Copy link
Owner

jgrss commented Oct 24, 2018

How did you install MpGlue? Did you build from source (below)?

python setup.py build && python setup.py install

@takaakimasaki
Copy link
Author

Yes I did install mpglue. But it still returns an error: This is the entire error message I got:

import mpglue as gl
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pysal/init.py:65: VisibleDeprecationWarning: PySAL's API will be changed on 2018-12-31. The last release made with this API is version 1.14.4. A preview of the next API version is provided in the pysal 2.0 prelease candidate. The API changes and a guide on how to change imports is provided at https://pysal.org/about
), VisibleDeprecationWarning)
Traceback (most recent call last):
File "", line 1, in
File "/Users/takaakimasaki/Dropbox/programming/python/mpglue/mpglue/init.py", line 3, in
from .classification.classification import classification, classification_r
File "/Users/takaakimasaki/Dropbox/programming/python/mpglue/mpglue/classification/classification.py", line 26, in
from ._moving_window import moving_window
ModuleNotFoundError: No module named 'mpglue.classification._moving_window'

@jgrss
Copy link
Owner

jgrss commented Oct 25, 2018

The _moving_window module is a Cython module, so let's see if it compiled properly.

  1. Do you see _moving_window.so under
    /Users/takaakimasaki/Dropbox/programming/python/mpglue/mpglue/classification?
  2. If no to (1), do you have Cython installed?
  3. If yes to (2), do you see a list of .pyx files when running python setup.py build && python setup.py install?

@takaakimasaki
Copy link
Author

Yes, I do see all those files. But still says "ModuleNotFoundError: No module named 'mpglue.classification._moving_window'"... Not sure what's driving this error.

@jgrss
Copy link
Owner

jgrss commented Oct 28, 2018

Can you uninstall mpglue, rebuild and install and post the tail of the traceback?

@takaakimasaki
Copy link
Author

Thank you so much for looking into this. I actually tried to do it on my Windows PC and still got the same error message... Any help you can provide on this would be much appreciated!

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\acer\Dropbox\programming\Python\mpglue\mpglue_init_.py", line 3, in
from .classification.classification import classification, classification_r
File "C:\Users\acer\Dropbox\programming\Python\mpglue\mpglue\classification\classification.py", line 26, in
from ._moving_window import moving_window
ModuleNotFoundError: No module named 'mpglue.classification._moving_window'

@vdeluca
Copy link

vdeluca commented May 23, 2019

Hi, I've the same error when I import mpglue from python shell
This is my complete trace:

  1. Build and Install
    https://paste.ofcode.org/r5DYguwXtxU8kRffza3ZaL

  2. pip install
    https://paste.ofcode.org/YmXu7xVdcfms7MJHF79GYx

  3. import
    https://paste.ofcode.org/EyvF7GA9g8FTz3f7hLx2VZ

Thanks, so much!

@vdeluca
Copy link

vdeluca commented May 23, 2019

Also, this is the classification's dir content

https://paste.ofcode.org/ZnbEvHTZbq8YtY7F25VdG

@vdeluca
Copy link

vdeluca commented May 23, 2019

Solved!
Was my fault unzip mpglue folder at the same point to access the python shell,

import mpglue
the .so files were compiled into virtual envoiroment path

Also, I must to install 2 pypi extra, Fiona and shapely

@jgrss
Copy link
Owner

jgrss commented May 23, 2019

@takaakimasaki where are you importing mpglue from on your terminal? See below if you are attempting to import from within your mpglue Git directory.

Looking at the traceback of @vdeluca I can see that the installation was clean. However, in the (3. import) test you were inside the mpglue Git directory that you pulled. If you pip install then the package is installed into your environment /site-packages directory. The mpglue Git directory doesn't have any .pyx extensions compiled. Therefore, if you try to import mpglue from within the Git directory, Python will first attempt to import the relative package, when the correct installed package is in your /site-packages.

You can check where you environment /site-packages directory is located by importing another package, like:

>>> import numpy as np
>>> print(np.__file__)

To test the installation of mpglue, cd somewhere like your home directory so that Python cannot see the Git directory.

@jgrss
Copy link
Owner

jgrss commented May 23, 2019

Here is an example of what I was referring to in the previous comment.

> git clone https://github.com/jgrss/mpglue/
> cd mpglue/
# activate a virtual environment if you have one
> python setup.py build && pip install --upgrade --user .
> cd ~
> python -c "import mpglue"

If you do not cd outside of the Git directory after building then it won't import the correct package. If, however, you want to use the Git directory as the import, you would need to do something like:

> git clone https://github.com/jgrss/mpglue/
> cd mpglue/
> # activate a virtual environment if you have one
> python setup.py build_ext --inplace
# add this Git directory path to PYTHONPATH

@jgrss
Copy link
Owner

jgrss commented May 23, 2019

Also, this is the classification's dir content

https://paste.ofcode.org/ZnbEvHTZbq8YtY7F25VdG

@vdeluca The above link should be related to the same issue. The import fails because you are missing the compiled files (.so files) inside the Git directory. If you check the mpglue /site-packages directory after installation, you should see the .so files.

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

3 participants