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

WindowsError: [Error 2] | a file can't be found #11

Closed iNaD closed 11 years ago

iNaD commented 11 years ago
Writing file __INSERT_FILENAME_HERE with encoding UTF-8
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 190, in on_post_save
  File ".\sublime_plugin.py", line 154, in run_timed_function
  File ".\sublime_plugin.py", line 189, in <lambda>
  File ".\sublime-wakatime.py", line 159, in on_post_save
  File ".\sublime-wakatime.py", line 130, in handle_write_action
  File ".\sublime-wakatime.py", line 71, in api
  File ".\subprocess.py", line 633, in __init__
  File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 2] Das System kann die angegebene Datei nicht finden

The last sentence is (translated) something like: The system can't find the given file

So WakaTime isn't tracking any time :( I hope you know a fix or can find a fix. I will have a look into the plugin.

pato commented 11 years ago

I experienced the exact same issue running Windows, Sublime Text 2 and WakaTime. The issue that you are experiencing is that python cannot be found. Make sure that you have python 2.7 installed (Wakatime didnt work nicely with Python 3.3) and that the python directory is in your Windows path.

Additionally, Alan fixed various issues so you should ensure that you have the latest version of the plugin via:

  1. Press ctrl+shift+p
  2. Type upgrade
  3. Choose Package Control: Upgrade/Overwrite All Packages

Hopefully that resolves your issue!

iNaD commented 11 years ago

Edit: Haha you've been faster than me ;) Yea I tried to fix it for Python 3.x, but there are too many old dependencies which have to be replaced or refactored, so I decided to install Python 2.x.


Old comment:

Ok so I have installed python now the error doesn't appear. Maybe this should be mentioned in the Readme for Windows users (It's not natural for Win users to have python installed and in PATH). Isn't it possible to use Sublime Text's python to execute the commands? I'm not familiar with Sublime Text plugin development, so I'm not sure about this.

Yours Daniel

pato commented 11 years ago

I agree with you. Unfortunately, I am also not familiar with plugin development but it seems like it would be a nice addition! If not possible, then a mention of having Python in the PATH in the readme should be enough.

Glad it worked! I've been using the plugin for two days and I love it :)

iNaD commented 11 years ago

Hehe :+1: You could have same try-error cases to maintain a Python 2.x and 3.x version, but that would be too much hassle to maintain. If it uses the integrad python compiler of Sublime Text you don't have to worry about Python versions and stuff.

alanhamlett commented 11 years ago

@iNaD so this error is fixed in the current plugin version?

pato commented 11 years ago

@alanhamlett Yes, it wasn't an error in your code, it was the fact that Python wasn't in the PATH

alanhamlett commented 11 years ago

Awesome! I'll close the issue now.

iNaD commented 11 years ago

Should I make instructions for Windows Users as pull request? (My english is not the best, but I will to correct my mistakes as good as I can)

alanhamlett commented 11 years ago

I can use sys.executable to set the python path for the subprocess command.

iNaD commented 11 years ago

That executes / uses the integrated python of st? If so, then it would be good to use it. As I mentioned before, not every Win user got python runtime installed =]

alanhamlett commented 11 years ago

Yes, on Windows it would return the ST embedded python interpreter.

Although I'm not sure if Windows needs to use pythonw to prevent a GUI window opening.

iNaD commented 11 years ago

After saving there's no GUI window opening with pythonw, but still the cursor turns into a spinning cursor while the subprocess is running. Maybe it's also fixed by using the embedded interpreter.

alanhamlett commented 11 years ago

@iNaD after testing, ST returns python3 from sys.executable so that's not going to work because an absolute path is needed.

Commit 998d0b2066 trys to execute python and then looks for python.exe in C:\python* This will work if Windows users install Python to the default path.

iNaD commented 11 years ago

Hmm default path of the python installer is C:\pythonXX where XX is the version number (ex. Python 2.7 defaults to C:\Python27

But thanks anyway you tried to solve this. I know it's not easy to handle dependencies like this on Windows without delivering it with your application.

alanhamlett commented 11 years ago

@iNaD C:\python27 would be picked up by the glob C:\python* then the plugin will look for python.exe inside C:\python27 so this should fix the issue.