-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Can't use Spyder to open python scripts (.py files) from the terminal or the file explorer #466
Comments
From DavidAnt...@gmail.com on 2010-11-24T17:44:56Z An existing feature which may solve your problem is that you can drag and drop files onto the spyder editor. This works for me under windows, I guess it should also work on linux. |
From ccordoba12 on 2010-11-27T10:13:19Z Thanks for your suggestion David, but I thinks it's not good enough. Instead of just double click on a py file and open it, right now you have to open spyder first and drag and drop it, which as I said it's kind of awkward. I'll try to implement this feature during my winter break, hope to make it for 2.1. Pierre, do you have any suggestions about where to start to look? |
From miniw...@gmail.com on 2010-11-29T03:06:43Z This probably can be donne with argparse module : https://code.google.com/p/argparse/ (before 2.7) http://docs.python.org/dev/library/argparse.html |
From ccordoba12 on 2010-12-01T10:45:20Z Owner: ccordoba12 |
From pierre.raybaut on 2010-12-01T10:51:51Z In current implementation, the command line options are parsed here in spyder.py: https://code.google.com/p/spyderlib/source/browse/spyderlib/spyder.py#1428 (the function 'get_options' uses the standard library module 'optparse') |
From pierre.raybaut on 2011-01-07T04:46:57Z issue #509 has been merged into this issue. |
From ccordoba12 on 2011-03-06T15:02:41Z Hi, I've added this functionality to the clone named ccordoba12-open-file. It's a simple change, but I wanted to put it in a separate branch, because now that this is in place there are two further things that could need more development:
Please clone the repo and check if it's working fine on Windows and Mac. I've only tested on Linux. Cheers, |
From ccordoba12 on 2011-03-06T15:40:34Z There is another thing I forgot the mention:
|
From pierre.raybaut on 2011-03-09T13:21:42Z
If files are opened with spyderlib.plugins.Editor.load, points 2. and 3. will be automatically solved. I'll take a look at it on Windows - I'm on Linux for now (I can't test it from MacOS...). |
From mortba...@gmail.com on 2011-05-11T22:15:28Z
Another enhancement would be to open a file per right click and say open with spyder. |
From ccordoba12 on 2011-05-14T15:04:35Z Thanks for your encouragement!! I'll try to solve this issue for 2.1 (the next release), although it has proven to be a bit beyond my programming skills. Let's see what we can do about it. |
From ccordoba12 on 2011-10-29T06:26:07Z I didn't make it for 2.1. Sorry. There were a lot of other things to take care of, but I work on it for 2.2. Labels: -Milestone-Release2.1 Milestone-Release2.2 |
From billhugh...@gmail.com on 2012-02-17T08:33:01Z I've been spreading the word about Spyder to all of my customers who are mainly Windows users. Great IDE but +1 for Right Click, open with spyder. This is kinda critical for us and allows use of the IDE with other .net applications we use. |
From ccordoba12 on 2012-02-17T12:28:35Z Hi Bill, it's definitely in my radar for 2.2 (hopefully a summer edition). I'm glad you like Spyder. |
From pierre.raybaut on 2012-03-11T06:13:17Z The "Open with Spyder" context menu entry feature is going to be platform-dependent, so let's open an issue for Windows to start with -- see issue #971 . |
From pierre.raybaut on 2012-03-18T13:45:45Z Labels: -Milestone-Release2.2 Milestone-v2.2 |
From pierre.raybaut on 2012-03-18T13:56:53Z Labels: -Milestone-v2.2 MS-v2.2 |
From pierre.raybaut on 2012-03-18T14:15:40Z Labels: -Type-Enhancement Type-Enh |
From pierre.raybaut on 2012-04-21T06:59:52Z issue #999 has been merged into this issue. |
From ccordoba12 on 2012-07-04T07:51:38Z Blocking: spyderlib:1089 |
From ccordoba12 on 2012-07-08T08:51:09Z issue #1112 has been merged into this issue. |
From techtonik@gmail.com on 2012-07-09T01:04:38Z Blocking: spyderlib:1112 |
From c.ed.m...@gmail.com on 2012-08-04T21:45:16Z Spyder is a fantastic IDE, and I really appreciate everyone's work. As for constructive comments, I think, as mentioned in comment 10, that the opening should be done without the -o argument. This is simple because argparse supports collecting the remaining "free-floating" arguments which could just be treated as a list of files. On that note, opening several files is important. i.e. spyder a.py b.py c.py should open all three. If possible, it would be nice to support spyder *.py to open all python files in the working directory. This could be implemented fairly simply (might require manually checking for '*.py' in the file argument and then handling it accordingly - use some sort of glob function to collect the files) Thanks for all your hard work! |
From c.ed.m...@gmail.com on 2012-08-05T20:17:28Z Hi All, I don't exactly know how the project is structured or how to contribute, but I've implemented the features I described above in my clone: https://code.google.com/r/cedmead-command-line-open/ It's a pretty simple modification of the features ccordoba12 implemented in his clone. |
From ccordoba12 on 2012-08-05T20:30:06Z Hey man, thanks a lot for taking the time to contribute code to solve this feature! During last month I implemented this feature too, with the addition of opening files in an existing instance. Unfortunately, I haven't had time to test it on Windows, just on Linux, but I hope to push it soon. |
From ccordoba12 on 2013-03-16T09:19:20Z Pierre confirmed to me that this is working for him. Now it's up to him to add context menu integration for Windows, as described by Jed in comment Status: Fixed |
From peter.sc...@gmail.com on 2013-04-21T18:08:17Z Hello, also thanks from my side for the great Spyder IDE. I use it under Ubuntu Precise Pangolin atm. I have a problem with the context menu support. I was able to get Spyder into the context menu, but when I try to open a file with it, Spyder starts but with the last session, instead of opening the intended file. How can I fix this? Best regards |
From ccordoba12 on 2013-04-21T18:24:53Z What Spyder version are you using? |
From peter.sc...@gmail.com on 2013-04-24T06:00:25Z Sry, forgot to add... Originally, I used the version in the Ubuntu repository but I switched to the debian package to fix this issue (which didn't work). So, currently I've got Spyder 2.1.10. Thx in advance for your help! |
From ccordoba12 on 2013-04-24T09:03:24Z I thought so. This feature is not present in version 2.1 but in (the about to be released) 2.2, so that's why is not working for you. I think there is a debian package in testing, or you can use our PPA: https://launchpad.net/~pythonxy/+archive/pythonxy-devel |
From peter.sc...@gmail.com on 2013-04-24T15:17:19Z Works like a charm! Thx for your immediate support and please keep on going with this project! Best regards |
From ccordoba12 on 2013-04-24T15:31:25Z Glad you like it! |
From Zsolt....@gmail.com on 2013-05-29T20:42:11Z I would like to say thanks that this got implemented and is working perfectly on Windows. However there is a bug:
A super easy fix is to:
So the correct version is: |
From ccordoba12 on 2013-05-30T10:25:09Z I guess you are trying to assign Spyder directly to open python files by selecting its .bat script. That's not how we planned things, because on Windows .py files are meant to be opened with the Python interpreter. Our solution is to install an "Open with" entry that can be accessed through your context menu. But to get that entry you need to use our Windows installers because they are not installed when one uses pip or easy_install |
From Zsolt....@gmail.com on 2013-05-30T10:42:15Z No, I'm using Total Commander and I'd like to associate it's Alt + F3 editor to open .py files by Spyder. Everything works perfectly, except for the black command line being visible. This is not related to Total Commander or anything, it would happen if I'd call the bat file from command line as well. It works perfectly, it just needs the last line to be changed to |
From ccordoba12 on 2013-05-30T10:56:41Z Ok, I understand, but I think it would easier to just use: "start /b python.exe %PYFILE% %*" However, I'm not a Windows expert and so I defer the decision to Jed or Pierre |
From Zsolt....@gmail.com on 2013-05-30T11:47:11Z The "%~f0...." has been there I believe because not everyone adds python to the PATH. The pythonw.exe is needed over python.exe because the python.exe creates the stupid command window and waits for the process to terminate before closing. http://stackoverflow.com/questions/9705982/pythonw-exe-or-python-exe /B - we don't want to wait for the process here, so we shouldn't use /B but it works for some reason both with and without /B. I don't know which is the better one. |
From jed.lud...@gmail.com on 2013-05-30T12:17:12Z Actually, there is a specific reason for not using pythonw.exe. See issue #1260 and the accompanying discussion on the mailing list. The Windows console should disappear after launch if you have installed pywin32 extensions: http://sourceforge.net/projects/pywin32/ The ...win32 name is unfortunate now because they actually work for x64, too. Just have to download the right build for your particular combination of OS and Python: http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/ |
From ccordoba12 on 2013-05-30T13:17:02Z Jed, does the window close too even if you start Spyder by double clicking its bat file? I thought that worked only when you run it through bootstrap.py. |
From Zsolt....@gmail.com on 2013-05-30T13:29:19Z For me, the only way to stop the window appearing is to start with pythonw. I use the Anaconda distribution, which bundles Spyder by default. Is it possible that this doesn't bundle pywin32? How can I test? 'import pywin32'? |
From jed.lud...@gmail.com on 2013-05-30T13:55:30Z Yes, the console will go away even when double clicking the .bat file. Even more, if you open a command window, cd to the spyder.bat directory, and launch the .bat from the command line the command window will disappear. Anaconda does not ship with pywin32: http://docs.continuum.io/anaconda/pkgs.html To test from the command line, try this: import win32con If that fails, then pywin32 is not installed. |
From ccordoba12 on 2013-05-30T13:58:52Z Yes, I was reading its supplied packages and couldn't find pywin32 (but I thought it wasn't there because its a scientific library per se). Then I think we should talk with Continuum guys to try to convince them to ship Anaconda with it. |
From ccordoba12 on 2013-06-07T09:13:52Z issue #1434 has been merged into this issue. |
Is there a working implementation at this yet? UAH student body needs to be able to open files at the terminal emulator within python instead of dragging and dropping. for example... spyder rando.py |
@r0cketdyne, that should be working. I mean, we have tests for it and they are passing right now. If that's not the case for you, please open a new issue and don't forget to fill our required information. Or better yet, open an issue directly from Spyder (by going to the menu entry |
I'll proceed to open with a new issue. Doing so internally might not be the most streamlined way to deal with this given the nature of the error I'm getting here: perhaps I should be using bash? I'll investigate and try to troubleshoot, or open a PR. |
I just brew installed spyder on my MAC M2. It would not even allow me to select a .py file in the browser. I cut&pasted the python I was working on in Linux yesterday into it and found the environment very useful. When I went to save some small changes it wanted to save it in a .R file ???? The code I have is in git and works in linux. I do not want to start altering file name (that may cause bother on linux as well) Is the default spyder5 configured for the R language or is broken in some way ? update: I tried again after re-installing. |
Hi @robin48gx I would say that the problem you are experiencing could be related with #22248 A fix for that will be available as part of Spyder 5.5.6 Let us know if the info above helps! |
From ccordoba12 on 2010-11-24T19:32:22Z
I would like to write in a terminal
spyder foo.py
to open any python script directly with spyder. If you could do this, you could also associate spyder to open .py files with your file manager of preference (e.g. dophin or nautilus in linux).
In my humble opinion, this would be a great time saver and an important usability improvement. Right now you have to open spyder and look for the file you want to work on, which sometimes can be cumbersome.
Thanks,
Carlos
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=466
The text was updated successfully, but these errors were encountered: