adeel / timed

a command-line time tracker
adeel.github.com/timed
MIT License
109 stars 13 forks source link

error: [Errno 2] No such file or directory: '~/.timed' #16

Open mediter opened 6 years ago

mediter commented 6 years ago

I followed the instructions to install timed:

sudo -H pip install timed

the installation show no error. then I tried to use it, but the following error shows up:

zsh: command not found: timed

using pip show timed shows the following result:

Name: timed
Version: 0.35
Summary: command-line time tracking
Home-page: http://adeel.github.com/timed
Author: Adeel Ahmad Khan
Author-email: adeel@adeel.ru
License: BSD
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires: termcolor

after verifying both paths of executables for Python 2.7 and Python 3.6 are in .bash_profile

And using the following two commands to confirm the executable for "timed" is indeed installed in both locations:

cd /Library/Frameworks/Python.framework/Versions/2.7/bin
ls | grep timed

What am I doing wrong? Do I have to log-out & log-in or restart the computer after the installation?

Mac OS X 10.13.1 (17B1003)

mediter commented 6 years ago

just realised I am using iTerm, it have switched the default shell script to zsh instead of bash

mediter commented 6 years ago

after adding the two Python executable paths to .zshrc, using timed would show the following error:

error: [Errno 2] No such file or directory: '~/.timed'
mediter commented 6 years ago

only after using touch .timed to create an empty file, timed command would work as expected

adeel commented 6 years ago

Strange, that issue should have been fixed with https://github.com/adeel/timed/commit/de86965c5854142198f96b316aeae16dac08ed66.

mediter commented 6 years ago

in the official documentation for built-in function open():

Open file and return a corresponding file object. If the file cannot be opened, an OSError is raised.

'a' for appending (which on some Unix systems, means that all writes append to the end of the file regardless of the current seek position)

'+' open a disk file for updating (reading and writing)

it doesn't seem to offer the capability we need here, which is to create a file if none exists before.

adeel commented 6 years ago

The official documentation seems to be poor in this case, but "a+" does indeed create the file if it doesn't exist. See also this MO question.