naturomics / CapsLayer

CapsLayer: An advanced library for capsule theory
Apache License 2.0
362 stars 117 forks source link

ModuleNotFoundError: No module named 'capslayer' #27

Closed tobystaines closed 6 years ago

tobystaines commented 6 years ago

I cannot work out how to import and use the layers functions (for building my own model). Import CapsLayers works, so the module is installed and in the path, but if I try:

import CapsLayer.capslayer.layers.layers as cl #(or any other combination I can think of)

It results in:

ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 import CapsLayer.capslayer.layers.layers as cl C:\Program Files\Anaconda3\lib\site-packages\CapsLayer\capslayer\__init__.py in () 1 from __future__ import absolute_import 2 ----> 3 from capslayer import layers 4 from capslayer import data 5 from capslayer.ops import losses ModuleNotFoundError: No module named 'capslayer'
tobystaines commented 6 years ago

I'm still not sure what caused this problem, but having restarted the kernel in my notebook this seems to be working fine now. How embarrassing!

the-moose-machine commented 6 years ago

I can confirm that this issue still exists. I am running this on Linux. Restarting the machine does not make any difference. I am trying to run the file called models/main.py. This file is unable to see capslayer/plotlib/figure.py since the target file is beyond the parent directory. Running main.py from the main directory and renaming the locations of the imports is also not working due to further import complications.

This has to be fixed by adding the following lines at the top of the file:

import sys
sys.path.append('..')
sys.path.append('.')

These lines were deleted in the last edit. I wonder why. A pull request has been created to rectify this.