So this all worked perfect on a different machine. Have had to get it to work on my desktop. pyenv
is installed there with different versions I just added miniconda3-latest
which displays nicely in the prompt (there is a .python-version
file in the directory below) Then ran pip install pymysql
after that prompt. When I run python now at that prompt it imports fine:
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>>
...but if I launch jupyter notebook
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $ jupyter notebook
[I 13:38:28.714 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
[I 13:38:29.216 NotebookApp] The port 8888 is already in use, trying another port.
[I 13:38:29.224 NotebookApp] [nb_conda] enabled
[I 13:38:29.278 NotebookApp] [nb_anacondacloud] enabled
[I 13:38:29.337 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 13:38:29.337 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 13:38:29.340 NotebookApp] Serving notebooks from local directory: /home/cardamom/Desktop/Project
[I 13:38:29.340 NotebookApp] 0 active kernels
[I 13:38:29.341 NotebookApp] The Jupyter Notebook is running at: http://localhost:8889/
[I 13:38:29.341 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
and try to import I get
ImportError Traceback (most recent call last)
<ipython-input-1-a4103d9b2333> in <module>()
----> 1 import pymysql
ImportError: No module named 'pymysql'
As I said, it works perfectly on a different machine.. Does anyone know how to get jupyter notebook, once launched, to correctly pick up the version which pyenv is reading from its .python-version
file?
In the mean time I have 90% solved it. From this article on the topic I found this pyenv which command had never tried before. So can see that there are two things that can be called.
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $ which jupyter
/home/cardamom/.pyenv/shims/jupyter
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $ pyenv which jupyter
/home/cardamom/.pyenv/versions/miniconda3-latest/bin/jupyter
Jupyter notebook seems to call the first one but if I enter the second path with the word 'notebook' after if, it launches fine and there is only one kernel available being the one with my pymysql module in it:
import sys
print (sys.version)
3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
Just need to work out how to call that directly without the whole path..
Update 15.05.17
Well, I fixed it, or helped it to fix itself -
rm -rf /home/cardamom/.pyenv/shims/jupyter*
Then closed and relaunched the terminal.
Surely wasn't the cleanest way, hope it hasn't broken something else, but now at least just running jupyter notebook
is launching a notebook which contains the kernel active in my directory miniconda3-latest. The two which
commands as per above are still returning the same thing, but now if I list the jupyter things in the first directory:
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $ ll /home/cardamom/.pyenv/shims/jupyter*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-bundlerextension*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-console*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-kernelspec*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-migrate*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-nbconvert*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-nbextension*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-notebook*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-qtconsole*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-run*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-serverextension*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-troubleshoot*
-rwxr-xr-x 1 cardamom cardamom 402 May 15 15:55 /home/cardamom/.pyenv/shims/jupyter-trust*
(miniconda3-latest) cardamom@pegasus ~/Desktop/Project $
...you can see that all those files just recreated themselves just a few minutes ago.