Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_logs.py fails when "php" is not available (OSError: [Errno 2] No such file or directory) #4835

Closed
anonymous-matomo-user opened this issue Mar 10, 2014 · 6 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.

Comments

@anonymous-matomo-user
Copy link

Since 5 days, my piwik import_logs.py do nothing.
See the following error.

root@s15879177:~# python /var/www/tools/piwik/misc/log-analytics/import_logs.py --url=https://mywebsite/piwik/ --idsite=1 --show-progress --recorders=4 --enable-reverse-dns --useragent-exclude=oui-moi-cmoi --exclude-path=/robots.txt --exclude-path=/ubuntu/* --exclude-path=/public/ubuntu/* --exclude-path=*.svg.php /var/log/lighttpd/access.log.6.gz
Traceback (most recent call last):
  File "/var/www/tools/piwik/misc/log-analytics/import_logs.py", line 1722, in <module>
    config = Configuration()
  File "/var/www/tools/piwik/misc/log-analytics/import_logs.py", line 570, in __init__
    self._parse_args(self._create_parser())
  File "/var/www/tools/piwik/misc/log-analytics/import_logs.py", line 560, in _parse_args
    self.options.piwik_token_auth = self._get_token_auth()
  File "/var/www/tools/piwik/misc/log-analytics/import_logs.py", line 607, in _get_token_auth
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
@anonymous-matomo-user
Copy link
Author

I'm using Piwik 2.1.0.

Ok!

The problems come from the php command (line 603): command = updatetokenfile
My system does not has php command, but has php-cgi command.

@mattab
Copy link
Member

mattab commented Mar 16, 2014

Thanks for the bug report!

What is the result of "which php" on your system?

Maybe we could use this command to find out which php to use.

@anonymous-matomo-user
Copy link
Author

Command which php return nothing:

root@s15879177:~# which php
root@s15879177:~# which php-cgi
/usr/bin/php-cgi

I'm using lighttpd 1.4.33 and php 5.5.9 on Debian testing.
But I don't know why php-cgi doesn't work since few weeks:

root@s15879177:~# php-cgi -v
Sun Mar 16 10:47:35 2014 (3293): Fatal Error Unable to allocate shared memory segment of 67108864 bytes: mmap: Cannot allocate memory (12)

@anonymous-matomo-user
Copy link
Author

I am having a very similar problem but not sure if exactly the same because my line numbers are a tad different. I am using apache to pipe its output to the import_logs.py file. After reading above I discovered that in my environment php is located at /usr/local/bin/php but the script is running as root which does not have that directory in its path. To fix this for myself I inserted a line in the import_logs.py file which I listed below. I know this is only a fix for my environment but just thought I'd let you know about this bug.

#= My Fix
I added this line to import_logs.py towards the top after the "import" section.

os.environ["PATH"] = os.environ["PATH"] + ":/usr/local/bin"

#= Error Output

Traceback (most recent call last):
  File "/hwnet/dtg_devel/web/boarddev/applications/piwik/misc/log-analytics/import_logs.py", line 1718, in <module>
    config = Configuration()
  File "/hwnet/dtg_devel/web/boarddev/applications/piwik/misc/log-analytics/import_logs.py", line 570, in __init__
    self._parse_args(self._create_parser())
  File "/hwnet/dtg_devel/web/boarddev/applications/piwik/misc/log-analytics/import_logs.py", line 560, in _parse_args
    self.options.piwik_token_auth = self._get_token_auth()
  File "/hwnet/dtg_devel/web/boarddev/applications/piwik/misc/log-analytics/import_logs.py", line 607, in _get_token_auth
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

#= Configuration

Piwik: 2.1.0
Python: 2.6.6
PHP: 5.5.10

@anonymous-matomo-user anonymous-matomo-user added this to the 2.5.0 - Piwik 2.5.0 milestone Jul 8, 2014
@mattab mattab removed the P: normal label Aug 3, 2014
@scholtzmi
Copy link

Hello together,
are there any fixes for that Problem? I am using Piwik 2.6.1 and have a similar error output.

Traceback (most recent call last):
  File "import_logs.py", line 1768, in <module>
    config = Configuration()
  File "import_logs.py", line 581, in __init__
    self._parse_args(self._create_parser())
  File "import_logs.py", line 571, in _parse_args
    self.options.piwik_token_auth = self._get_token_auth()
  File "import_logs.py", line 662, in _get_token_auth
    credentials = open(filename, 'r').readline()
IOError: [Errno 2] No such file or directory: 'X-Powered-By: PHP/5.4.16\r\nContent-type: text/html\r\n\r\n/<my directory>/piwik/tmp/cache/token.php   

@mattab
Copy link
Member

mattab commented Mar 12, 2015

Issue was moved to the new repository for Piwik Log Analytics: https://github.com/piwik/piwik-log-analytics/issues

refs #7163

@mattab mattab closed this as completed Mar 12, 2015
@mattab mattab added the duplicate For issues that already existed in our issue tracker and were reported previously. label Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously.
Projects
None yet
Development

No branches or pull requests

3 participants