0

I have installed Anaconda (x64 Linux) and I am running its Python 3.

When I type which python, I get

/home/hinckelbc/anaconda3/bin/python

Now to display the version, I type python -V, and I get

Python 3.6.4 :: Anaconda, Inc.

Which is normal, since I am running Python 3 from Anaconda

If I launch Spyder from the terminal by simply typing spyder, it will launch and I see that the Python interpreter is indeed the Python 3 from Anaconda, as shown below:

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Type "copyright", "credits" or "license" for more information.

IPython 6.2.1 -- An enhanced Interactive Python.

!which python
/home/hinckelbc/anaconda3/bin/python

! python -V
Python 3.6.4 :: Anaconda, Inc.

The Spyder running on my machine is the following:

hinckelbc@BCArg:~$ which spyder
/home/hinckelbc/anaconda3/bin/spyder

In order to avoid opening the terminal all the time and typing spyder, I have created the following spyder.desktop file ~/.local/share/applications/spyder.desktop, which looks like this:

[Desktop Entry]
Type=Application
Name=Spyder
Exec=/home/hinckelbc/anaconda3/bin/spyder
Icon=/home/hinckelbc/anaconda3/pkgs/spyder-3.2.6-py36_0/info/icon.png
Terminal=false

I then could find Spyder with the Super key, which was then added to by launcher, by dragging and dropping (Gnome 3, Ubuntu 17.10)

However, when I open Spyder by clicking on the icon, now on my favorites, I get:

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Type "copyright", "credits" or "license" for more information.

IPython 6.2.1 -- An enhanced Interactive Python.

! which python
/usr/bin/python

! python -V
Python 2.7.14

Which does not agree with the python interpreter I set manually on Spyder, as shown below:

Spyder preferences screenshot

Does anyone know how to solve this, i.e. to get Python 3 running on Spyder with the desktop icon I have created and added to my favourites?

0

Your environment is different.

The spyder terminal inherits the PATH variable from its parent, the Spyder process, who has different env: - When launching spyder from PATH is the one of shell, which includes .../conda/bin because of your .bashrc / .zshrc - When launching from .desktop, the env is the one with /etc/profile (and maybe .profile ?)

In short, one solution is to launch through your shell:

Exec='bash -c .../spyder'

...and make sure that you add conda/bin to your PATH in .bash_profile, or see [How to load .bashrc from “bash -c”][1].

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.