I came back to pycharm for a project from SublimeText and updated to Pycharm 2020.1.2, I needed to quickly run a .py file, but when I double click the file, it opens the script in a view where I can edit but not run, so every time I have to go to File->Open File in Project. I don't remember having to do that in earlier versions of Pycharm, how can I circumvent that and always have Pycharm open a .py file in Project view?
You started PyCharm in the light edit mode, check this blog post https://blog.jetbrains.com/idea/2020/04/lightedit-mode/
I also have pycharm and usually I do Right click on the file -> open with -> pycharm
your problem does not seem a big deal. the problem is that you are using 'the editor' of PyCharm.
see this picture below of my system:
when you right-click on a .py file and choose 'Edit with PyCharm', you use the simple editor of PyCharm. not the Debugger.
If you click on anywhere else on the window(not on a file), you see the option 'Open Folder as PyCharm Project' (if you do not have this option, reinstall PyCharm and check this option in PyCharm setup wizard), like the picture below:
now if you choose this option, PyCharm will open your whole folder as a project, and you have python console, terminal, debugger, and whatever you want.
these 2 pictures below, show differences between this 2 mode:
Edit with Pycharm:
you can see in this mode you have no option for running and debugging your code. just an editor.
Open Folder as PyCharm Project
in this mode, you will see you have full options for running and debugging, python console, terminal, and so on...
so you see, in your first picture, when you select 'Open File in Project' in PyCharm Editor mode, it looks like you are opening this file by pressing 'Open Folder as PyCharm Project' in your folder. so if you open your folder as a PyCharm project, you do not need to do this all the time for running you code.
Related
I installed PyCharm, but later I found out that VSCode is better. Even later I found out you can run the code inside a file without compiling it and without opening an editor.
My questions are:
How can I change the default app for .py to VSCode?
How can I set it to run when clicked on it without any app?
P.S. - I was having a little fun with regedit before and found that Python has its own set of reg keys. Can it help? (I'm on Windows.)
Right click the file → open with → Choose another app → Check vscode and check the line below
In Windows 10 Right-Click on the file. Click on Open With and choose Other Apps. Here you should see Visual Studio Code. Click on it and on the bottom select "Always open .py files with this app".
(I use Linux as my main system, so I tried to remember the names of the Button. So I dont know if it is the correct spelling and text. I am sorry for that.)
I'm setting up my home computer for basic python development. I've managed to install Anaconda through the command line but I'm not sure how to make .py files run through the Anaconda interpreter when double-clicked.
i.e. I did this on my Windows computer at work by right clicking on a .py file and then choosing open with > open with another application > navigating to {C:\Users\\AppData\Local\Continuum\anaconda3} > clicking on python.exe and then clicking 'open'. Is there an equivalent way of doing this on Linux? I'm running Pop!_OS.
I've tried clicking 'open with' but there was no option to open with another application. I also wouldn't know what type of file I would be looking for whereas I knew in Windows I was looking for a .exe
I've also tried right clicking on a .py file, going on the 'Permissions' tab, checking the box for 'Allow executing file as a program' and going to Files > preferences > Behaviour and changed the Executable Text Files option from 'Display them' to 'Run them'.
The most common way on linux to make things executable is by adding the executable flag to the file. On command line, if your file is called script.py:
chmod +x script.py
It is important that your script starts with a description of how to execute it.
For python, your script should start with:
#!/usr/bin/env python
Also, for clarification, there is no .exe file in Linux. The equivalent to that is the previously mentioned executable flag.
How to set Spyder as default program for Python file? This question has been asked over and over in here and here. I looked around, there still isn't an answer.
I want to click on a .py file, and open it in Spyder. Instead of, opening Sypder from Terminal, then go to File > open. I'm using a Mac.
This question was asked as early as 2013. It's now 2018!
Steps:
Download the spyder-mac-app.zip archive. Unarchive it to
/Applications
Edit the /Applications/Spyder.app/Contents/MacOS/Spyder file to launch the right environment of Spyder, e.g.:
#!/bin/sh
$HOME/anaconda3/envs/tensorflow/bin/spyder $#
Launch Spyder from Finder to verify that Finder is launching as expected.
Install duti and run duti -s org.spyder .py all
Right click any .py file in Finder, click Get Info In Open with menu, select Other and navigate to 'Applications. Select Spyder, Press Add and Click on Change All in Info menu.
Here is the rundown (seen here: Change Default App For File On Mac):
Right Click File
Click Get Info
Click Open With Dropdown
Choose The App
Click Change All
If Asked Click Continue
I recently installed PyCharm. Now when I run a *.py file from the command line, PyCharm opens up and tries to create a project - every time! I close PyCharm, try to run the file from cmd, PyCharm opens back up and interferes. Is there any way to prevent this? Thanks.
Try removing .py file's association. By right clicking on any .py files > properties > general tab > Opens with > Change
I have installed Anaconda, but I do not know how to open a .py file..
If it is possible, please explain plainly, I browsed several threads, but I understood none of them..
Thanks a lot for your helps..
Best,
In the menu structure of your operating system, you should see a folder for Anaconda. In that folder is an icon for Spyder. Click that icon.
After a while (Spyder loads slowly) you will see the Spyder integrated environment. You can choose File then Open from the menu, or just click the Open icon that looks like an open folder. In the resulting Open dialog box, navigate to the relevant folder and open the relevant .py file. The Open dialog box will see .py, .pyw, and .ipy files by default, but clicking the relevant list box will enable you to see and load many other kinds of files. Opening that file will load the contents into the editor section of Spyder. You can view or edit the file there, or use other parts of Spyder to run, debug, and do other things with the file.
As of now, there is no in-built way to load a .py file in Spyder directly from the operating system. You can set that up in Windows by double-clicking a .py file, then choosing the spyder.exe file, and telling Windows to always use that application to load the file. The Anaconda developers have said that a soon-to-come version of Anaconda will modify the operating system so that .py and other files will load in Spyder with a double-click. But what I said above works for Windows.
This answer was a bit condensed, since I do not know your level of understanding. Ask if you need more details.
You can use any text editor to open a .py file, e.g. TextMate, TextWrangler, TextEdit, PyCharm, AquaMacs, etc.