0

I am using a package that requires me to add the following line to my bashrc

export PATH=${PATH}:~/cozmo/plataform-tools

It works perfectly when I call python3 or ipython3 from the command line. However, when I start Spyder by double clicking a python file in Nautilus, it cannot find and execute a required file that is inside that folder. So, my question is

How to make the spyder console to use the PATH set at my bashr? Or how to set the path inside spyder?

I am aware of Why do the environment variables set in command prompt have no effect when I start Spyder, but it don't solve my problem, since I need to call it from Nautilus (and not use sudo) and I do not want to add a line declaring the path in all my programs.

bmello
  • 1,864
  • 3
  • 18
  • 23

2 Answers2

4

(Spyder maintainer here) For Spyder to take notice of any environment variable set in your .bashrc, you need to start it from a terminal.

This is because Spyder doesn't have the ability to read environment variables when started in a graphical way.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • 1
    Thank you Carlos, it worked. Is there a way I can set the variable in the spyder console, so it can be started in a graphical way. – bmello Nov 22 '17 at 00:42
  • Not at the moment, sorry. We're aware of this limitation and we'll try to improve the situation in the future, but we don't concrete plans to do it at the moment. – Carlos Cordoba Nov 22 '17 at 22:02
3

I found a solution to setting a variable in ipython console. Just include

import os, os.environ['PATH']+=':/home/bernardo/cozmo/platform-tools

in Tools → Preference → iPython console → Startup → Lines. I believe a similar solution can be applied if Python console is being used instead of iPython console.

By doing this I am able to use the package that requires this path even when spyder is not started from the terminal.

bmello
  • 1,864
  • 3
  • 18
  • 23