1

Regular PyCharm, Anaconda and Jupyter user, but for the first time I'm starting a project that would benefit with having them all play together:

I have a correctly configured Anaconda environment running within PyCharm, however when I try to launch ipynb notebooks (that work perfectly well in jupyter notebook from within PyCharm, I get...

/home/bolster/anaconda3/bin/python3.5 /home/bolster/anaconda3/bin/jupyter-notebook --no-browser --ip 127.0.0.1 --port 8888
[W 12:33:12.515 NotebookApp] Unrecognized JSON config file version, assuming version 1
[W 12:33:12.519 NotebookApp] Config option `matplotlib` not recognized by `NotebookApp`.
[W 12:33:12.521 NotebookApp] Config option `matplotlib` not recognized by `NotebookApp`.
Traceback (most recent call last):
  File "/home/bolster/anaconda3/bin/jupyter-notebook", line 6, in <module>
    sys.exit(notebook.notebookapp.main())
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1069, in initialize
    self.init_configurables()
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 837, in init_configurables
    parent=self,
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/nb_conda_kernels/manager.py", line 19, in __init__
    specs = self.find_kernel_specs() or {}
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/nb_conda_kernels/manager.py", line 129, in find_kernel_specs
    self.conda_info = self._conda_info()
  File "/home/bolster/anaconda3/lib/python3.5/site-packages/nb_conda_kernels/manager.py", line 29, in _conda_info
    p = subprocess.check_output(["conda", "info", "--json"]
  File "/home/bolster/anaconda3/lib/python3.5/subprocess.py", line 629, in check_output
    **kwargs).stdout
  File "/home/bolster/anaconda3/lib/python3.5/subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/bolster/anaconda3/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/home/bolster/anaconda3/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'conda'

I have a hunch that this is because PyCharm isn't attempting to launch the notebook in a "real" user environment and as such isn't getting my $PATH imports (in .profile), however as this isn't a "Run Configuration" I can't see any way to "point" the IDE to look in the right path for the conda executable.

However if I add a link to the conda executable to /usr/bin/, it works, but this is an order of hackery on a collaborative project that I'm not exactly happy with.

Is there a way to force PyCharm to look in the right place or at least update the internal-global environment variables to avoid seriously telling collaborators they need to link from their userland environment to the root bins?

Bolster
  • 7,460
  • 13
  • 61
  • 96
  • I'm using python 2.7 and anaconda2 and I had a similar error. When I switched the conda environment to another one the notebook was launched. Though my error was from removing conda-build and conda-env so I could install packages via conda on my environment. – lurknobserve Jul 27 '16 at 14:42

1 Answers1

2

Any application started from the terminal will inherit all the properties from the terminal. If you start the PyCharm the non-terminal way then the $PATH defined in the .profile won't be inherited and so the default $PATH.

Started the PyCharm from the shell and then $PATH from the .profile was inherited. Now, PyCharm is able to found conda in the path.

Another way is to create a .sh file in the /etc/profile.d folder with the PATH variable. These variables are system wide. So, there is no need to start PyCharm from the terminal now.

The reason for such a behavior and alternate solutions are specified in this StackOverflow post.

Hope this helps!

Community
  • 1
  • 1
Praveen Sripati
  • 32,799
  • 16
  • 80
  • 117