Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work within individual files rather than projects in PyCharm

Tags:

python

pycharm

Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects.

Is there a way to configure Pycharm to be used to open single files and not use projects?

Similarly, is it possible to just run a single page/file?

like image 877
Steven Evans Avatar asked Jul 07 '13 14:07

Steven Evans


People also ask

How do I run an individual Python file in PyCharm?

Any Python file shown in your folder can be run by right/control clicking on it and selecting in the dropdown menu: Run <name of file without . py> Alternately you can click on the top menu item Run, and in the dropdown menu click on Run... and the current file should appear there. You can click on it.

How do I switch between projects in PyCharm?

Switching between projects To switch between open projects, you can use the following commands of the Window menu: Window | Next Project Window Ctrl+Alt+] Window | Previous Project Window Ctrl+Alt+[


2 Answers

On Pycharm 5.0.4...

  1. Open the file (i.e. by double clicking in explorer)
  2. Navigate to File->Settings...
  3. Expand the Project tab on the left and select 'project interpreter' from the options that appear beneath
  4. Set your project interpreter from the dropdown menu, and you should be able now to run your file without creating a project
like image 91
tvt173 Avatar answered Sep 22 '22 05:09

tvt173


You can always open a single file (File > Open) but to actually run or debug the code from within Pycharm, or use most of its other features, it needs a correctly configured project.

What you can do is create a single project to hold all of your "assorted" code. I usually recommend creating a virtualenv for this project as well and using that as your Pycharm project interpreter. You can further divide this project into different packages to keep things organized.

Update: PyCharm 4.5 now provide Scratch Files which seem relevant to this question.

like image 26
Preston Landers Avatar answered Sep 22 '22 05:09

Preston Landers