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
Removing Punctuations and Spaces in a String Without Using Regex
How to Add a Delay to Message.Delete()
Conversion of String to Upper Case Without Inbuilt Methods
Discord.Py Show Who Invited a User
Python: Using Doctests for Classes
How to Prevent Brokenpipeerror When Doing a Flush in Python
Count Frequency of Words in a List and Sort by Frequency
How to Find the Average of Particular Numbers in a CSV File
Google Chrome Closes Immediately After Being Launched With Selenium
Python-3: Why This Following Code Returns None in Print Statement
Combine Year, Month and Day in Python to Create a Date
Merge Multiple Rows to Single Row - Pandas
Stored Procedures With Sqlalchemy
Pyodbc Error Data Source Name Not Found and No Default Driver Specified Paradox
How to Cleanly Uninstall Ansible
How to Append Data Using Openpyxl Python to Excel File from a Specified Row