Set Working Directory in Python/Spyder So That It's Reproducible

How to set working directory pemanently in Spyder & RStudio?

To set working directory permanently in:
1. Spyder IDE: Tools > Prefeences > Current working directory > the following directory
2. RStudio IDE: Tools > Global Options... > General > Default working directory (when not in a project)

PS: Yes, we need to restart the application in both IDEs to take
changes in effect.

python: Change the scripts working directory to the script's own directory

This will change your current working directory to so that opening relative paths will work:

import os
os.chdir("/home/udi/foo")

However, you asked how to change into whatever directory your Python script is located, even if you don't know what directory that will be when you're writing your script. To do this, you can use the os.path functions:

import os

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

This takes the filename of your script, converts it to an absolute path, then extracts the directory of that path, then changes into that directory.

Spyder Exception hyperlinks not working with modules located in subfolders of global working directory

(Spyder dev here) I think you have found a bug :-) If you want this fixed, please: 1) Open an issue in our issue tracker (else I'll forget it for sure), and 2) Upload there a simple but reproducible example I can use to test and debug what's happening.

How to use pep8 module using Spyder

(Spyder maintainer here) You can activate pep8 support in Spyder 3 by going to

Tools > Preferences > Editor > Code Introspection/Analysis

and activating the option called

Real-time code style analysis

This will show pep8 warnings directly in our Editor, so you don't need to run pep8 from the command line to see them.

How can I prevent Spyder from inserting a new line after taking user input?

(Spyder developer here) This looks like a minor bug in our IPython console. Please report it here:

https://github.com/jupyter/qtconsole

Note: This console is not simply embedding a terminal IPython session in Spyder (that's why making comparisons to it make no sense at all).

Instead, it is a re-implementation of most of the terminal behavior but using a graphical toolkit (called Qt) and the Jupyter kernel/frontend architecture.



Related Topics



Leave a reply



Submit