0

On linux I am managing Python via anaconda. However, as there was no good support for amplpy, I installed that via pip.

Now, When I am in ipython, I can do

In [1]: import amplpy
In [3]: amplpy
Out[3]: <module 'amplpy' from '/home/x/anaconda3/envs/myenv3/lib/python3.6/site-packages/amplpy/__init__.py'>

and similarly if I run from bare python. However, when I start jupyter notebook

(myenv3) x:yy$ jupyter notebook

and open a fresh python 3 sheet, I get

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-93ba964328c9> in <module>()
----> 1 import amplpy

ModuleNotFoundError: No module named 'amplpy'

sys.path gives me

['',
 '/home/x/anaconda3/lib/python36.zip',
 '/home/x/anaconda3/lib/python3.6',
 '/home/x/anaconda3/lib/python3.6/lib-dynload',
 '/home/x/anaconda3/lib/python3.6/site-packages',
 '/home/x/anaconda3/lib/python3.6/site-packages/Sphinx-1.5.6-py3.6.egg',
 '/home/x/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg',
 '/home/x/anaconda3/lib/python3.6/site-packages/IPython/extensions',
 '/home/x/.ipython']

Which is the wrong folder! ipython has /home/x/anaconda3/envs/myenv3/lib/... as path!

What can cause such inconsistency, and how do I fix it?

FooBar
  • 15,724
  • 19
  • 82
  • 171
  • 1
    Yes, I am certain – FooBar Sep 27 '17 at 09:02
  • If you use `conda install jupyter` to install jupyter, you can choose which kernel to use. Check menu `Kernel->Change kernel`. Is there any other option? – Sraw Sep 27 '17 at 09:06
  • @Sraw Should there be a "Kernel" menu inside Jupyter notebook? I have none. But when I am creating a new notebook, I can choose between `python3` and `julia`, and I am choosing the former. – FooBar Sep 27 '17 at 09:09
  • You should find a "Kernel" menu when you are editing a notebook. But it seems not the point... Could you check `sys.path` in notebook? – Sraw Sep 27 '17 at 09:16
  • Possible duplicate of [Keras import error Nadam](https://stackoverflow.com/questions/38809686/keras-import-error-nadam) – ivan_pozdeev Sep 27 '17 at 09:16

1 Answers1

1

Most probably, you've installed the module to a different environment than the one your jupyter command is using (e.g. if there' no jupyter in your "myenv3", whatever else is found on the PATH will be used). See e.g. Keras import error Nadam for troubleshooting tips.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152