<p><aclass="reference external"href="https://www.jetbrains.com/pycharm/">PyCharm</a> is a Python developer’s IDE from Jetbrains available for Windows, Mac and Linux.
It is a commercial product but offer free trials, a scaled-down community edition and also generous licenses for OSS projects like Evennia.</p>
<p>First, download and install the IDE edition of your choosing.
The community edition should have everything you need,
but the professional edition has integrated support for Django which can help.</p>
<sectionid="from-an-existing-project">
<h2>From an existing project<aclass="headerlink"href="#from-an-existing-project"title="Permalink to this headline">¶</a></h2>
<p>Use this if you want to use PyCharm with an already existing Evennia game.
First, ensure you have completed the steps outlined <aclass="reference external"href="https://www.evennia.com/docs/latest/Setup/Installation.html#requirements">here</a>.
Especially the virtualenv part, this will make setting the IDE up much easier.</p>
<olclass="simple">
<li><p>Open Pycharm and click on the open button, open your root folder corresponding to <codeclass="docutils literal notranslate"><spanclass="pre">mygame/</span></code>.</p></li>
<li><p>Click on File -> Settings -> Project -> Python Interpreter -> Add Interpreter -> Add Local Interpreter
You should create two new folders, one for the root of your project and one
for the evennia game directly. It should look like <codeclass="docutils literal notranslate"><spanclass="pre">/location/projectfolder/gamefolder</span></code></p></li>
<li><p>Select the <codeclass="docutils literal notranslate"><spanclass="pre">Custom</span><spanclass="pre">environment</span></code> interpreter type, using <codeclass="docutils literal notranslate"><spanclass="pre">Generate</span><spanclass="pre">New</span></code> of type <codeclass="docutils literal notranslate"><spanclass="pre">Virtual</span><spanclass="pre">env</span></code> using a
compatible base python version as recommended in <aclass="reference external"href="https://www.evennia.com/docs/latest/Setup/Installation.html#requirements">https://www.evennia.com/docs/latest/Setup/Installation.html#requirements</a>
Then choose a folder for your virtual environment as a sub folder of your project folder.</p></li>
<li><p>Type in <codeclass="docutils literal notranslate"><spanclass="pre">pip</span><spanclass="pre">install</span><spanclass="pre">evennia</span></code></p></li>
<li><p>Close the IDE and navigate to the project folder</p></li>
<li><p>Rename the game folder to a temporary name and create a new empty folder with the previous name</p></li>
<li><p>Open your OS terminal, navigate to your project folder and activate your virtualenv.
On linux, <codeclass="docutils literal notranslate"><spanclass="pre">source</span><spanclass="pre">.evenv/bin/activate</span></code>
On windows, <codeclass="docutils literal notranslate"><spanclass="pre">evenv\Scripts\activate</span></code></p></li>
<li><p>Type in <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">--init</span><spanclass="pre">mygame</span></code></p></li>
<li><p>Move the files from your temporary folder, which should contain the <codeclass="docutils literal notranslate"><spanclass="pre">.idea/</span></code> folder into
the folder you have created at step 3 and delete the now empty temporary folder.</p></li>
<li><p>In the terminal, Move into the folder and type in <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">migrate</span></code></p></li>
<li><p>Start evennia to ensure that it works with <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">start</span></code> and stop it with <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">stop</span></code></p></li>
<li><p>Launch Evennia in the pycharm terminal</p></li>
<li><p>Attempt to start it twice, this will give you the process ID of the server</p></li>
<li><p>In the PyCharm menu, select <codeclass="docutils literal notranslate"><spanclass="pre">Run</span><spanclass="pre">></span><spanclass="pre">Attach</span><spanclass="pre">to</span><spanclass="pre">Process...</span></code></p></li>
<li><p>From the list, pick the corresponding process id, it should be the <codeclass="docutils literal notranslate"><spanclass="pre">twistd</span></code> process with the <codeclass="docutils literal notranslate"><spanclass="pre">server.py</span></code> parameter (Example: <codeclass="docutils literal notranslate"><spanclass="pre">twistd.exe</span><spanclass="pre">--nodaemon</span><spanclass="pre">--logfile=\<mygame\>\server\logs\server.log</span><spanclass="pre">--python=\<evennia</span><spanclass="pre">repo\>\evennia\server\server.py</span></code>)</p></li>
<p>You can attach to the <codeclass="docutils literal notranslate"><spanclass="pre">portal</span></code> process as well, if you want to debug the Evennia launcher
or runner for some reason (or just learn how they work!), see Run Configuration below.</p>
<blockquote>
<div><p>NOTE: Whenever you reload Evennia, the old Server process will die and a new one start. So when you restart you have to detach from the old and then reattach to the new process that was created.</p>
<h3>Run Evennia with a Run/Debug Configuration<aclass="headerlink"href="#run-evennia-with-a-run-debug-configuration"title="Permalink to this headline">¶</a></h3>
<p>This configuration allows you to launch Evennia from inside PyCharm.
Besides convenience, it also allows suspending and debugging the evennia_launcher or evennia_runner
at points earlier than you could by running them externally and attaching.
In fact by the time the server and/or portal are running the launcher will have exited already.</p>
<sectionid="on-windows">
<h4>On Windows<aclass="headerlink"href="#on-windows"title="Permalink to this headline">¶</a></h4>
<li><p>Go to <codeclass="docutils literal notranslate"><spanclass="pre">Run</span><spanclass="pre">></span><spanclass="pre">Edit</span><spanclass="pre">Configutations...</span></code></p></li>
<li><p>Click the plus-symbol to add a new configuration and choose Python</p></li>
<li><p>Add the script: <codeclass="docutils literal notranslate"><spanclass="pre">\<yourprojectfolder>\.evenv\Scripts\evennia_launcher.py</span></code> (substitute your virtualenv if it’s not named <codeclass="docutils literal notranslate"><spanclass="pre">evenv</span></code>)</p></li>
<li><p>Ensure the chosen interpreter is your virtualenv</p></li>
<li><p>Set Working directory to your <codeclass="docutils literal notranslate"><spanclass="pre">mygame</span></code> folder (not your project folder nor evennia)</p></li>
<li><p>You can refer to the PyCharm documentation for general info, but you’ll want to set at least a config name (like “MyMUD start” or similar).</p></li>
<li><p>Go to <codeclass="docutils literal notranslate"><spanclass="pre">Run</span><spanclass="pre">></span><spanclass="pre">Edit</span><spanclass="pre">Configutations...</span></code></p></li>
<li><p>Click the plus-symbol to add a new configuration and choose Python</p></li>
<li><p>Add the script: <codeclass="docutils literal notranslate"><spanclass="pre">/<yourprojectfolder>/.evenv/bin/twistd</span></code> (substitute your virtualenv if it’s not named <codeclass="docutils literal notranslate"><spanclass="pre">evenv</span></code>)</p></li>
<li><p>Set script parameters to: <codeclass="docutils literal notranslate"><spanclass="pre">--python=/<yourprojectfolder>/.evenv/lib/python3.11/site-packages/evennia/server/server.py</span><spanclass="pre">--logger=evennia.utils.logger.GetServerLogObserver</span><spanclass="pre">--pidfile=/<yourprojectfolder>/<yourgamefolder>/server/server.pid</span><spanclass="pre">--nodaemon</span></code></p></li>
<li><p>Add an environment variable <codeclass="docutils literal notranslate"><spanclass="pre">DJANGO_SETTINGS_MODULE=server.conf.settings</span></code></p></li>
<li><p>Ensure the chosen interpreter is your virtualenv</p></li>
<li><p>Set Working directory to your game folder (not your project folder nor evennia)</p></li>
<li><p>You can refer to the PyCharm documentation for general info, but you’ll want to set at least a config name (like “MyMUD Server” or similar).</p></li>
<li><p>Go to <codeclass="docutils literal notranslate"><spanclass="pre">Run</span><spanclass="pre">></span><spanclass="pre">Edit</span><spanclass="pre">Configutations...</span></code></p></li>
<li><p>Click the plus-symbol to add a new configuration and choose Python</p></li>
<li><p>Add the script: <codeclass="docutils literal notranslate"><spanclass="pre">/<yourprojectfolder>/.evenv/bin/twistd</span></code> (substitute your virtualenv if it’s not named <codeclass="docutils literal notranslate"><spanclass="pre">evenv</span></code>)</p></li>
<li><p>Set script parameters to: <codeclass="docutils literal notranslate"><spanclass="pre">--python=/<yourprojectfolder>/.evenv/lib/python3.11/site-packages/evennia/server/portal/portal.py</span><spanclass="pre">--logger=evennia.utils.logger.GetServerLogObserver</span><spanclass="pre">--pidfile=/<yourprojectfolder>/<yourgamefolder>/server/portal.pid</span><spanclass="pre">--nodaemon</span></code></p></li>
<li><p>Add an environment variable <codeclass="docutils literal notranslate"><spanclass="pre">DJANGO_SETTINGS_MODULE=server.conf.settings</span></code></p></li>
<li><p>Ensure the chosen interpreter is your virtualenv</p></li>
<li><p>Set Working directory to your game folder (not your project folder nor evennia)</p></li>
<li><p>You can refer to the PyCharm documentation for general info, but you’ll want to set at least a config name (like “MyMUD Portal” or similar).</p></li>
<p>You should now be able to start both modes and get full debugging.
If you want to go one step further, you can add another config to automatically start both.</p>
<olclass="simple">
<li><p>Go to <codeclass="docutils literal notranslate"><spanclass="pre">Run</span><spanclass="pre">></span><spanclass="pre">Edit</span><spanclass="pre">Configutations...</span></code></p></li>
<li><p>Click the plus-symbol to add a new configuration and choose Compound</p></li>
<li><p>Add your two previous configurations, name it appropriately and press Ok.</p></li>
</ol>
<p>You can now start your game with one click with full debugging active.</p>