I am trying to run/debug my python project from IntelliJ Ultimate 2018.1. I have defined a python SDK, a Django local server (as the project uses Django as a template language), the PYTHONPATH is properly defined, etc. If I execute
python manage.py runserver
from my MacOS terminal, the server starts normally. When I am trying to run my IntelliJ configuration, it fails, with message:
/usr/bin/python2.7 -d /Users/my_user/dev/github/my_project/manage.py runserver 8000
Traceback (most recent call last):
File "/Users/my_user/dev/github/my_project/manage.py", line 19, in <module>
paths = importlib.import_module('settings.' + server + '.paths')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/my_user/dev/github/my_project/settings/__init__.py", line 11, in <module>
paths = importlib.import_module('my_project.settings.' + server + '.paths')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named my_project.settings.local.paths
The settings.local
folder does contains the __init__.py
file, and also settings
folder and the root folder of my project.
Doing a few hours of research over the internet I have realised that the main problem is to include local modules on the classpath, so they are available for server startup. For PyCharm, this is clearly explained here, and I was able to run the server from PyCharm. However, when trying to do the same thing in IntelliJ, this never works. Some people write about it here for example, but that didn't worked out for me.
I have tried using a system interpreter and also a virtual environment, created with PyCharm, with no luck. I am using python 2.7, Django 1.11 and MacOS High Sierra. Is this even possible with IntelliJ? I wonder why would people buy PyCharm if the same things can be accomplished (and so much more) with IntelliJ. Also, I have noticed that when I change a setting in IntelliJ run profile (the Django local server profile), this change is reflected back in PyCharm and viceversa. This seems to me like a bug from JetBrains, as two distinct apps somehow share the same config, probably due to the fact that the same project is loaded in both apps.