-
Notifications
You must be signed in to change notification settings - Fork 315
"Edit with Spyder" should set cwd to .py file directory #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
well, if you know how to tweak the code here, I'll be interesting to see your pull request. https://github.com/winpython/winpython/blob/master/winpython/associate.py#L74..L98 maybe it's rather a Spyder problem, or another entry to add "edit wiith Spyder in this directory" |
I've discovered that changing the way "Edit with Spyder" is setup in the registry almost does what I want: In: (No, I don't know why this is in two places; I'm no expert on the Windows registry.) If the default entry there is changed to:
That almost makes Spyder set the working directory to the location of the .py file. The problem is that |
Maybe add ".." ? Or "." ? ~p1. |
That would change the front of the string, but not the end, which is where the problem is. I submitted a Spyder issue. See spyder-ide/spyder#9354 I suppose I could write a batch file that called a Python script that pre-processed the command line. But that really shouldn't be necessary. (And it would make Spyder load even slower.) |
|
@stonebig I think I misunderstood you. I just tried adding "." at the end of the path string. Yes, it seems to work to add a "." to the end of the path on the command line. But it doesn't work in the registry. I don't know why. I tried the dot on the other side of the closing quote, too. Still doesn't work. |
and with |
Tried Both work in the command line, neither in the registry. Don't know why. Is there a way to see what command line Spyder thinks it got? |
not a specialist for, and with |
seems there is no solution : even if you type the directory the "hard way" in the registery, it just fails to launch spyder. |
so there are a bit of research/experiment to do to figure it out. |
Sorry, a bit late (maybe it still helps someone xD) :The parameter-syntax is actually different for registry shell commands and the CMD shell! Searching for actually available syntax lead me to this thread: which contains a list of valid options:
So I simply tested the "%w"-parameter and it worked perfectly:
I tested in Win7, but I believe it will be the same in Win10. |
found this https://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
|
I'll change the spyder.bat scripts to this:
Does it fit the general purpose ?
|
Sounds good. |
If you want to solve it via a CMD batch file, then the parameter syntax is documented with the "for"-command: |
oups, is there something to tweak in the more readable associate.py ? |
Problem Description
When you right-click on a .py file and choose "Edit with Spyder", Spyder starts up with the working directory (os.getcwd) set to the Spyder settings directory.
In Preferences you can change this (I think) to one specific directory of choice, but only one.
When starting Spyder this way, the cwd should be set to the location of the ,py file.
(At least, that should be one of the options in Preferences.)
What steps reproduce the problem?
What is the expected output? What do you see instead?
cwd should be location of .py file.
Spyder version: 3.3.1
Python version: 3.7
Operating System name/version: Win 10 Pro x64
The text was updated successfully, but these errors were encountered: