Where are all the projects installed by python setup.py install?

I use python3.8 that comes with ubuntu 20.04, and I installed a project with python setup.py install. Now I want to put a configuration directory into the project, how can I find its installation location?

I am getting this error, do I need to set a PYTHONPATH environment variable? But where should this PYTHONPATH point to?

wajika@logstash02-new:~$ /home/wajika/supervisor/elastalert.sh 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/util.py", line 28, in get_module
    base_module = __import__(module_path, globals(), locals(), [module_class])
ModuleNotFoundError: No module named 'elastalert_modules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 516, in load_alerts
    alert_field = [create_alert(a, b) for a, b in alert_field]
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 516, in <listcomp>
    alert_field = [create_alert(a, b) for a, b in alert_field]
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 500, in create_alert
    alert_class = self.alerts_mapping.get(alert) or get_module(alert)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/util.py", line 31, in get_module
    raise EAException("Could not import module %s: %s" % (module_name, e)).with_traceback(sys.exc_info()[2])
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/util.py", line 28, in get_module
    base_module = __import__(module_path, globals(), locals(), [module_class])
elastalert.util.EAException: Could not import module elastalert_modules.wechat_qiye_alert.WeChatAlerter: No module named 'elastalert_modules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 156, in load
    rule = self.load_configuration(rule_file, conf, args)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 219, in load_configuration
    self.load_modules(rule, args)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 483, in load_modules
    rule['alert'] = self.load_alerts(rule, alert_field=rule['alert'])
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 519, in load_alerts
    raise EAException('Error initiating alert %s: %s' % (rule['alert'], e)).with_traceback(sys.exc_info()[2])
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 516, in load_alerts
    alert_field = [create_alert(a, b) for a, b in alert_field]
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 516, in <listcomp>
    alert_field = [create_alert(a, b) for a, b in alert_field]
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 500, in create_alert
    alert_class = self.alerts_mapping.get(alert) or get_module(alert)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/util.py", line 31, in get_module
    raise EAException("Could not import module %s: %s" % (module_name, e)).with_traceback(sys.exc_info()[2])
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/util.py", line 28, in get_module
    base_module = __import__(module_path, globals(), locals(), [module_class])
elastalert.util.EAException: Error initiating alert ['elastalert_modules.wechat_qiye_alert.WeChatAlerter']: Could not import module elastalert_modules.wechat_qiye_alert.WeChatAlerter: No module named 'elastalert_modules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/elastalert", line 11, in <module>
    load_entry_point('elastalert2==2.2.1', 'console_scripts', 'elastalert')()
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/elastalert.py", line 2151, in main
    client = ElastAlerter(args)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/elastalert.py", line 132, in __init__
    self.rules = self.rules_loader.load(self.conf, self.args)
  File "/usr/local/lib/python3.8/dist-packages/elastalert2-2.2.1-py3.8.egg/elastalert/loaders.py", line 164, in load
    raise EAException('Error loading file %s: %s' % (rule_file, e))
elastalert.util.EAException: Error loading file /home/wajika/elastalert2/es_rules/bpm.yaml: Error initiating alert ['elastalert_modules.wechat_qiye_alert.WeChatAlerter']: Could not import module elastalert_modules.wechat_qiye_alert.WeChatAlerter: No module named 'elastalert_modules'

No need to set PYTHONPATH, try running pip install --user . (or use a virtual environment) instead of running python setup.py install. This should put your installed package (and its dependencies) in a discoverable location.

On Ubuntu, python points to Python 2, which is both end-of-life (for two years now) and not installed in Ubuntu 20.04 by default, something to keep in mind.

To answer your initial question, the easiest way to find out the install folder in your case is to look at the traceback and find the file paths it displays. If you used pip install, you can get the install parent directory with pip show <package name>.

1 Like

Thank you for your answer. After posting, I also realized that the factors that may be caused by different user environments, I lack experience in Ubuntu using Python.

In addition, use the system’s own Python execute setup.py install and perform other versions of Python setup.py install in a normal user, such as Python3.10, where they are installed, is required to pay attention.

Also, to note, python setup.py install has been deprecated and strongly discouraged for many years now. pip install . is what you want to do instead.