Skip to content
Myr

update pycharm instructions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 3e5ca29 · Browse files · 3 files+22 added−39 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+22 added−39 removed

  • other:+22 added−39 removed

3 files+22 added−39 removed

added:docs/_static/pycharm-run-config.pngbinary

A binary file, added.

deleted:docs/_static/pycharm-runconfig.pngbinary

A binary file, deleted.

modified:docs/cli.rst+22 added-39 removed
550 unmodified lines
551552PyCharm Integration553-------------------554555PyCharm Professional provides a special Flask run configuration. For556the Community Edition, we need to configure it to call the ``flask run``557CLI command with the correct environment variables. These instructions558should be similar for any other IDE you might want to use.555PyCharm Professional provides a special Flask run configuration to run the development556server. For the Community Edition, and for other commands besides ``run``, you need to557create a custom run configuration. These instructions should be similar for any other558IDE you use.559560In PyCharm, with your project open, click on *Run* from the menu bar and561go to *Edit Configurations*. You'll be greeted by a screen similar to562this:560In PyCharm, with your project open, click on *Run* from the menu bar and go to *Edit561Configurations*. You'll see a screen similar to this:562564.. image:: _static/pycharm-runconfig.png563.. image:: _static/pycharm-run-config.png564 :align: center565 :class: screenshot567 :alt: Screenshot of PyCharms's run configuration settings.566 :alt: Screenshot of PyCharm run configuration.567569There's quite a few options to change, but once we've done it for one570command, we can easily copy the entire configuration and make a single571tweak to give us access to other commands, including any custom ones you572may implement yourself.568Once you create a configuration for the ``flask run``, you can copy and change it to569call any other command.570574Click the + (*Add New Configuration*) button and select *Python*. Give575the configuration a name such as "flask run". For the ``flask run``576command, check "Single instance only" since you can't run the server577more than once at the same time.571Click the *+ (Add New Configuration)* button and select *Python*. Give the configuration572a name such as "flask run".573579Select *Module name* from the dropdown (**A**) then input ``flask``.574Click the *Script path* dropdown and change it to *Module name*, then input ``flask``.575581The *Parameters* field (**B**) is set to the CLI command to execute582(with any arguments). In this example we use ``run``, which will run583the development server.576The *Parameters* field is set to the CLI command to execute along with any arguments.577This example uses ``--app hello --debug run``, which will run the development server in578debug mode. ``--app hello`` should be the import or file with your Flask app.579585You can skip this next step if you're using :ref:`dotenv`. We need to586add an environment variable (**C**) to identify our application. Click587on the browse button and add an entry with ``FLASK_APP`` on the left and588the Python import or file on the right (``hello`` for example). Add an589entry with ``FLASK_ENV`` and set it to ``development``.580If you installed your project as a package in your virtualenv, you may uncheck the581*PYTHONPATH* options. This will more accurately match how you deploy later.582591Next we need to set the working directory (**D**) to be the folder where592our application resides.583Click *OK* to save and close the configuration. Select the configuration in the main584PyCharm window and click the play button next to it to run the server.585594If you have installed your project as a package in your virtualenv, you595may untick the *PYTHONPATH* options (**E**). This will more accurately596match how you deploy the app later.597598Click *Apply* to save the configuration, or *OK* to save and close the599window. Select the configuration in the main PyCharm window and click600the play button next to it to run the server.601602Now that we have a configuration which runs ``flask run`` from within603PyCharm, we can copy that configuration and alter the *Script* argument604to run a different CLI command, e.g. ``flask shell``.586Now that you have a configuration for ``flask run``, you can copy that configuration and587change the *Parameters* argument to run a different CLI command.