Scenario

Although Python is a cross-platform language, sometimes ya know, the package for Linux and Windows are not the same. This will be really annoying.

For example, when you write a Django project, you may use pymysql for MySQL database connection, which depends on mysqlclient, and then django-cors-headers, even uwsgi. However, for Windows, official package of mysqlclient doesn’t support Python 3.8+, while uwsgi doesn’t support Python 3.7-… 🤬 Therefore, we have to use Linux interpreter.

But we can only develop on Windows! That’s why this article is here.


Procedure

Step 1. Add SSH Interpreter

In project settings, click ‘Add Interpreter’ to add a new Python Interpreter, and choose ‘On SSH’.

image-20230514223454414

Then, just enter the host, port, username and password of your remote Linux server. If everything goes well, you can see the output panel of introspect like this.

image-20230514223810971

Step 2. Select Remote Interpreter

After introspecting, you should then select interpreter on the remote server. Yeah, conda, of course. And leave auto upload choice empty, since we won’t need this.

image-20230514224743379

Notice: The interpreter must be the exact Python executable file!

Then, just click ‘Create’, and then ‘Apply’, maybe.

Step 3. Configure Deployment

Now that we have a remote interpreter, but could not actually run on the remote server. So we have to deploy our project to the remote server.

Go to settings, go to ‘Deployment’ > ‘Mappings’, select the SSH server you just added, then your favorite deployment path. This is the absolute path on your remote server. You can simply ignore ‘Web path’. Finally, click ‘Apply’ to save the changes.

image-20230514231259971

Then, if you have some other requirements, you can go to ‘Options’ section to modify detailed deployment preference.

image-20230514230801653

At last, set the project’s remote server to what you just configured.

image-20230514231549584

Step 4. Sync with Remote Server

Now that you have configured everything, you can upload your project to the remote server. Right click on your project, then ‘Deployment’ > ‘Upload to ……’.

image-20230514231756938

Then, you can open the SSH terminal of your remote server and check those files. See, they’re there!

image-20230514232044799

Epilogue

Well, actually not that complicated, right? Hmm… I have to admit, that, 🙁, that PyCharm… does have its… Err… advantages. But, of course, still no match for Visual Studio. 🥰