Pycharm setup - xcist/documentation GitHub Wiki

Setting up from scratch.

Although there are many ways to set up a Python development environment, here is one way which we believe may be relatively low effort. The CatSim project uses Python 3 syntax. These instructions were written for Python 3.7, but may work for later versions as well.

Install Python

Follow the instructions for downloading and installing Python. We recommend using Python 3.7 or one of its 3.7.x maintenance releases.

Click the box to "Add Python 3.7 to PATH." Install with the default options rather than the custom installation.

Install PyCharm

Follow the instructions for downloading and installing PyCharm, getting the free Community Edition. NOTE: We will not use PyCharm for Anaconda for the time being. It seems to have some issues running with corporate firewalls.

We suggest selecting all options:

  • Create Desktop Shortcut
  • Update context menu
  • Create Associations -- unless you also have another Python environment on the same computer
  • Update PATH variable

Reboot your computer after installing PyCharm.

Run PyCharm

Double-click on the PyCharm icon on your desktop. If you are asked about importing settings, choose "Do not import settings" unless you know that you have previous settings that you want to use. You will then be asked for your preferred color scheme.

If you are behind a corporate firewall, PyCharm may fail to get the list of available plugins online. We will fix that later.

Click on "Start using PyCharm."

Proxy Settings

If you are working behind a corporate proxy server, you may need to update the proxy settings in order to download and install public Python packages.

When the "Welcome to PyCharm" dialog is shown, click on Customize-> All Settings.

pycharm-welcome.png

  • Expand the Appearance & Behavior section
  • Expand the System Settings section
  • Click on HTTP Proxy.
  • Enter the correct settings for your site. Many people find using manual settings easiest. The Automatic settings may be easy to copy from your browser settings.

pycharm-proxy-settings.png

  • Use the Check connection to confirm you can access sites inside your corporate network and on the Internet.

pycharm-check-proxy-settings.png

Successful connection:

pycharm-successful-test-connection.png

Failed connection:

pycharm-fail-test-connection.png

  • If your internal sites cannot be reached, adjust the items in the in "No proxy for" entry.
  • If external sites cannot be reached, contact your IT network team to get the correct settings. You may want to inspect your browser settings.
  • Click OK on the Settings dialog.

Users behind corporate firewalls may periodically get (frequent) dialogs about "Untrusted Server's Certificate." Click on "Accept." (A solution to this is being sought.)

Create a test project

Back on the "Welcome to Pycharm" dialog, click on "Create New Project."

pycharm-new-project.png

Enter the location for your new project by editing the provided path.

Expand the Project Interpreter section. The dialog may be filled out with these defaults:

  • Select the radio button for "New environment using" and choose "Virtualenv".

  • Location should be filled in automatically.

  • Base interpreter should also be filled in automatically for where you have installed python.exe.

    • If you have multiple installations of python, select the desired one (e.g. python 3.7).
  • Check the boxes to "Inherit global site-packages" and "Make available to all projects."

    • This will allow you to reuse your installation. However, if you have other work that has different requirements you may leave this unchecked, but then you will have to repeat package installations if you create multiple projects for CatSim work.
  • Check the box to add a main.py file to the project. This will create a simple test python file.

  • Click "Create."

PyCharm will take a couple of minutes to create the virtual environment, the new directory and files and open your new project.

If you forgot to check the box to add main.py file, then create a new file:

  • Under "Project" on the left panel, right-click on your project
  • Choose New -> Python File.
  • Give the file a name. (You don't need to add .py. This is added automatically.)
  • Add some python code to your new file:
print("Hello, python user")
  • Right-click on your filename and find the "Run myfile.py" in the menu.

pycharm-helloproject-run-start.png

  • If the Run item does not exist in the menu, then Python may still be doing some background tasks to initialize the environment - especially the first time you use python or a new python interpreter. Look for background tasks in the lower right status bar.

pycharm-background-startup.png

This should run your python program and show any output in the "Run" window.

pycharm-helloproject-run-results.png

Congratulations! You have got PyCharm set up and can start working with Python programs.