PyCharm setup - WikipediaLibrary/TWLight GitHub Wiki
PyCharm setup
This project can be set up via PyCharm using its support for Docker. Wikimedia developers can get free access to PyCharm Professional (required for Docker support) - please contact The Wikipedia Library team for instructions.
Process
- After installing Docker, ensure it's using Linux Containers, and in settings, enable the 'Expose daemon on tcp://localhost:2375 without TLS' option in settings.
- In PyCharm, open the repository folder, and navigate to Project Settings (File > Settings)
- Under Build, Execution, Deployment > Docker, click the + symbol and check the TCP socket option is selected. The value for Engine API URL should be
tcp://localhost:2375
. - In Settings, navigate to Project > Python Interpreter and click Add Interpreter in the top right, then On Docker Compose
- Configuration file(s) should be set to both
docker-compose.yml
anddocker-compose.override.yml
- Service should be set to
twlight
. - Set Python interpreter path to
/venv/bin/python3
(you will need to select the 'invalid' option in the dropdown)
- It may take some time for the interpreter to finish adding. If successful, you should see a long list of python packages including Django.
- Select Run > Edit Configurations
- Click the + to create a new Docker configuration
- Compose file(s) should again be set to both
docker-compose.yml
anddocker-compose.override.yml
- Click the Modify button next to
docker-compose up
, Build, then select Build > Always - Click Apply, then Ok
- Click Run > Run 'docker-compose.yml: Compose deployment'
- You should see the three containers -
twlight_docker_db_1
,twlight_docker_twlight_1
, andtwlight_docker_web_1
start up correctly, and you should see the platform atlocalhost
. - Whenever you want to start the Docker containers again, simply perform step 7.
Potential issues
Cannot start service db: driver failed programming external connectivity on endpoint...
: Occassional problem which stops docker containers from starting. To solve, simply restart the docker service.- 'Unauthorised' when retrieving alpine: This error is a result of signing into Docker with an ID rather than your email. Simply log out and then back in using your full email address.
- SDK name error: Clear out your PyCharm interpreters by following the top response at https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000306410-Cannot-use-system-interpreter-in-PyCharm-Pro-2018-1
Drive has not been shared
. This error occurs if Docker can't access the relevant folder. On Windows it can be solved by going to Properties > Sharing > Share > Share.(2005, "Unknown MySQL server host 'db' (-2)")
. Happens when the 'twlight_db_1' container fails to load. For a simple fix, open command prompt from within the Docker program files directory and rundocker system prune
. Deploying docker-compose.override.yml should now recreate the database from scratch. Run migrations, folowed by the example data script to restore the db to its initial state. Check out https://github.com/wodby/mariadb/issues/2 if you are interested in not a simple fix.- Docker services list in PyCharm lists items like 'secrets' and 'services' instead of 'twlight': Disable Docker-Compose V2 in Experimental Features in Docker Desktop.