I have already been able to run a certain module from the terminal. No I want to run the module with the run config on PyCharm. However it fails, even though I think I use the same configurations as in the terminal command. Or am I wrong?
The terminal command is:
lukas@lukas-XXXX:~/PycharmProjects/synapse$ source ./env/bin/activate
(env) lukas@lukas-XXXX:~/PycharmProjects/synapse$ python -m synapse.app.homeserver --config-path homeserver.yaml
For the run config I used the basic Python template and only changed the Module name, Parameters and Working directory. The Python interpreter should be the same as the environment that I have activated in the above command. Here is the config:
Running this produces the following error:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/home/lukas/PycharmProjects/synapse/synapse/app/__init__.py", line 18, in <module>
from synapse import python_dependencies # noqa: E402
File "/home/lukas/PycharmProjects/synapse/synapse/python_dependencies.py", line 29, in <module>
logger = logging.getLogger(__name__)
AttributeError: module 'logging' has no attribute 'getLogger'
The module is from the synapse project from matrix.org. The terminal command can be found here.
My assumption is that the logging
module accessed in python_dependencies.py
line 29 is resolved differently, depending on whether I start the module via the terminal or via PyCharm's run config. Using the terminal, it probably resolves to Python's standard libary module. Using the Run Config, it definitively uses synapse's logging
package. Also, when using PyCharm to navigate to the logging
package referenced to in python_dependencies.py
, PyCharm gets me to synapse's custom logging
module.
The big question is: Why? Shouldn't my Run Configuration do exactly the same as my terminal command? What am I missing?
Ok, somehow removing the marks at
PYTHONPATH
andPYTHONPATH
solved the issue.