Score:1

How to make Jupyter Notebook look in the right place for a module?

cn flag

Using a Jupyter Notebook running with the python2 kernel, I tried to import emcee and I got an error message:

File "/home/me/.local/lib/python2.7/site-packages/emcee/ensemble.py", line 84
    parameter_names: Optional[Union[Dict[str, int], List[str]]] = None,
                   ^
SyntaxError: invalid syntax

apparently because I am using the python2 kernel.

I then installed ipykernal using: python3 -m pip install ipykernel

I then opened a Jupyter Notebook using the Python3 kernel. I tried to import emcee but I had the same problem. It was still looking for the emcee module in the python2 path.

I then did pip3 install emcee, opened a Jupyter Notebook (python3 kernel) but I still have the same issue.

I think I need to tell Jupyter Notebook to look for the python3 version of emcee, but I'm not sure how to. I just tried:

export PYTHONPATH='/home/me/.local/lib/python3.6/site-packages/'

But again, this didn't fix it. I checked the sys.path in my Juoyter Notebook and the new python path didn't seem to be added.

Can someone tell me what I'm doing wrong please?

Score:0
cn flag

The Jupyter Notebook wasn't really using the python3 kernel even though it said it was:

My python3 kernel was located: /home/damejia/.local/share/jupyter/kernels/python3

The kernel.json file was:

{
 "argv": [
  "python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

But "python" just points to my python2. I changed "python" to "python3" and everything worked.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.