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
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.
In project settings, click ‘Add Interpreter’ to add a new Python Interpreter, and choose ‘On SSH’.
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.
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.
Notice: The interpreter must be the exact Python executable file!
Then, just click ‘Create’, and then ‘Apply’, maybe.
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.
Then, if you have some other requirements, you can go to ‘Options’ section to modify detailed deployment preference.
At last, set the project’s remote server to what you just configured.
Now that you have configured everything, you can upload your project to the remote server. Right click on your project, then ‘Deployment’ > ‘Upload to ……’.
Then, you can open the SSH terminal of your remote server and check those files. See, they’re there!
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. 🥰