wakatime / sublime-wakatime

Sublime Text 2 & 3 plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/sublime-text
BSD 3-Clause "New" or "Revised" License
526 stars 45 forks source link

Python interpreter can't find __main__ module #9

Closed alanhamlett closed 11 years ago

alanhamlett commented 11 years ago

~/.wakatime.log has this error: /usr/bin/python: can't find 'main' module in '/home/user/.config/sublime-text-3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime.py'

This has been reported on OS X and Ubuntu.

rabas commented 11 years ago

Can confirm this issue, OS X 10.8.4.

alanhamlett commented 11 years ago

This is possibly fixed in the latest version 0.2.7, but I haven't been able to reproduce it locally. @rabas can you please confirm this is fixed?

makeev commented 11 years ago

It is not fixed on Ubuntu, unfortunately:(

rabas commented 11 years ago

@alanhamlett No, I'm still getting the same error. Is there anything I can do in order to provide you with more details?

alanhamlett commented 11 years ago

@rabas can you go to your sublime Packages directory and cd into the WakaTime folder, then run these commands:

$ git pull
$ /usr/bin/python --version
$ /usr/bin/python ./packages/wakatime/wakatime-cli.py --help
$ /usr/bin/python ./packages/wakatime/wakatime-cli.py --time 1 --file ./packages/wakatime/wakatime-cli.py --verbose

Then copy/paste the output from the above commands. Can you also check $HOME/.wakatime.log and copy/paste the last line of that file?

jamesmoss commented 11 years ago

I'm getting the same problem on OSX 10.8.2 so I ran those commands.

Mossbook-Air:WakaTime james$ /usr/bin/python --version
Python 2.7.2
Mossbook-Air:WakaTime james$ /usr/bin/python ./packages/wakatime/wakatime-cli.py --help
usage: wakatime-cli.py [-h] --file file [--time time] [--endtime ENDTIME]
                       [--write] [--plugin PLUGIN] [--key KEY]
                       [--logfile LOGFILE] [--config CONFIG] [--verbose]
                       [--version]

Wakati.Me event api appender

optional arguments:
  -h, --help         show this help message and exit
  --file file        absolute path to file for current action
  --time time        optional floating-point unix epoch timestamp; uses
                     current time by default
  --endtime ENDTIME  optional end timestamp turning this action into a
                     duration; if a non-duration action occurs within a
                     duration, the duration is ignored
  --write            note action was triggered from writing to a file
  --plugin PLUGIN    optional text editor plugin name and version for User-
                     Agent header
  --key KEY          your wakati.me api key; uses api_key from
                     ~/.wakatime.conf by default
  --logfile LOGFILE  defaults to ~/.wakatime.log
  --config CONFIG    defaults to ~/.wakatime.conf
  --verbose          turns on debug messages in log file
  --version          show program's version number and exit
Mossbook-Air:WakaTime james$ /usr/bin/python ./packages/wakatime/wakatime-cli.py --time 1 --file ./packages/wakatime/wakatime-cli.py --verbose
Mossbook-Air:WakaTime james$ tail ~/.wakatime.log
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
/usr/bin/python: can't find '__main__' module in '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py'
python: can't open file '/Users/james/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime-cli.py': [Errno 2] No such file or directory
{"now": "Tue Jul 23 10:50:10 BST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/james/Library/Application Support/Sublime Text 3/Packages/WakaTime/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": "Sending action to api at https://www.wakati.me/api/v1/actions"}
{"now": "Tue Jul 23 10:50:10 BST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/james/Library/Application Support/Sublime Text 3/Packages/WakaTime/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"project": "WakaTime", "tags": ["master", "sublime-wakatime", "WakaTime"], "file": "/Users/james/Library/Application Support/Sublime Text 3/Packages/WakaTime/packages/wakatime/wakatime-cli.py", "time": 1.0}}
{"now": "Tue Jul 23 10:50:11 BST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/james/Library/Application Support/Sublime Text 3/Packages/WakaTime/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"response_code": 201, "response_content": "{\n  \"data\": {\n    \"id\": \"2860494b-d9d8-4b44-8586-d09c99226cae\"\n  }\n}"}}
jamesmoss commented 11 years ago

Also even after running /usr/bin/python ./packages/wakatime/wakatime-cli.py --time 1 --file ./packages/wakatime/wakatime-cli.py --verbose and getting a 201 response I'm not seeing any time in my account.

rabas commented 11 years ago

I'm using ST3, so I unzipped Wakatime.sublime-package found in Installed Packages dir, and run those commands with extracted files.

➜  wakatime git:(master) ✗ /usr/bin/python --version
Python 2.7.2
➜  wakatime git:(master) ✗ /usr/bin/python ./wakatime-cli.py --help 
usage: wakatime-cli.py [-h] --file file [--time time] [--endtime ENDTIME]
                       [--write] [--plugin PLUGIN] [--key KEY]
                       [--logfile LOGFILE] [--config CONFIG] [--verbose]
                       [--version]

Wakati.Me event api appender

optional arguments:
  -h, --help         show this help message and exit
  --file file        absolute path to file for current action
  --time time        optional floating-point unix epoch timestamp; uses
                     current time by default
  --endtime ENDTIME  optional end timestamp turning this action into a
                     duration; if a non-duration action occurs within a
                     duration, the duration is ignored
  --write            note action was triggered from writing to a file
  --plugin PLUGIN    optional text editor plugin name and version for User-
                     Agent header
  --key KEY          your wakati.me api key; uses api_key from
                     ~/.wakatime.conf by default
  --logfile LOGFILE  defaults to ~/.wakatime.log
  --config CONFIG    defaults to ~/.wakatime.conf
  --verbose          turns on debug messages in log file
  --version          show program's version number and exit
➜  wakatime git:(master) ✗ /usr/bin/python ./wakatime-cli.py --time 1 --file ./packages/wakatime/wakatime-cli.py --verbose

Last few lines in .wakatime.log are:

/usr/bin/python: can't find '__main__' module in '/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/packages/wakatime/wakatime.py'
{"now": "Tue Jul 23 12:23:46 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/packages/wakatime/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": "File does not exist; ignoring this action."}

Edit: Here are some new lines from log:

{"now": "Tue Jul 23 13:11:34 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": "Sending action to api at https://www.wakati.me/api/v1/actions"}
{"now": "Tue Jul 23 13:11:34 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"project": "rabas", "tags": ["rabas"], "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "time": 1.0}}
{"now": "Tue Jul 23 13:11:36 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"response_code": 201, "response_content": "{\n  \"data\": {\n    \"id\": \"f4e28585-1a25-49de-888e-d558debf2136\"\n  }\n}"}}
{"now": "Tue Jul 23 13:13:32 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": "Sending action to api at https://www.wakati.me/api/v1/actions"}
{"now": "Tue Jul 23 13:13:32 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"project": "rabas", "tags": ["rabas"], "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "time": 1.0}}
{"now": "Tue Jul 23 13:13:33 CEST 2013", "version": "0.1.4", "time": 1.0, "file": "/Users/rabas/Library/Application Support/Sublime Text 3/Installed Packages/extracted/packages/wakatime/wakatime-cli.py", "level": "DEBUG", "message": {"response_code": 201, "response_content": "{\n  \"data\": {\n    \"id\": \"f40cde08-ab73-4719-8cef-1125f97ca347\"\n  }\n}"}}
rabas commented 11 years ago

I just installed plugin on ST2, and it seems to be working, so the issue is related to ST3 only.

Edit:

Removed package form Package Control, downloaded .zip from github, and moved unzipped package to Packages, folder, and it seems to be working now (ST3).

alanhamlett commented 11 years ago

Ok, I know what's going on now. WakaTime gets installed as a sublime-package archive, but needs to be fully extracted as source code (not .pyc files) into the Packages directory to work.

I posted a question here to see if anyone knows how to force Sublime Text 3 to always extract .sublime-package archives: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=13427

Sublime Text 2 always extracts the package into the Packages folder, so this error only occurs on ST3 correct?

For now, you can manually extract the WakaTime.sublime-package into the Packages folder to get it working.

alanhamlett commented 11 years ago

Fixed as of b944863cb729d2c6560d3740371f9d71b6167f1f.

Adding a .no-sublime-package file to the repository forces ST3 to extract the plugin into the Packages directory. Updating WakaTime from these instructions will fix this issue: https://www.wakati.me/help/plugins/sublime#upgrade

alanhamlett commented 11 years ago

For anyone who experienced this issue, you will need to manually delete WakaTime.sublime-package and re-install using these instructions:

  1. Run rm -rf $HOME/Library/Application Support/Sublime Text 3/Installed Packages/WakaTime.sublime-package/
  2. Edit your Sublime Package Control list of installed packages to make sure WakaTime is not listed:

    $HOME/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings

  3. Re-install WakaTime using Sublime Package Control with these instructions: https://www.wakati.me/help/plugins/sublime#package-control-install
alanhamlett commented 9 years ago

Huh? O_o