Spyder: OSError when creating a project

Created on 6 May 2020  路  8Comments  路  Source: spyder-ide/spyder

Description

What steps will reproduce the problem?

Project -> new, then checklist the existing directory and choosing a directory with python files. I was able to create and manage a project in the same directory with and old sypder version (spyder 3)

Traceback

  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/spyder/plugins/projects/plugin.py", line 284, in _create_project
    self.open_project(path=path)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/spyder/plugins/projects/plugin.py", line 330, in open_project
    self.watcher.start(path)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/spyder/plugins/projects/utils/watcher.py", line 153, in start
    raise e
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/spyder/plugins/projects/utils/watcher.py", line 128, in start
    self.observer.start()
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/api.py", line 253, in start
    emitter.start()
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/utils/__init__.py", line 110, in start
    self.on_thread_start()
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify.py", line 121, in on_thread_start
    self._inotify = InotifyBuffer(path, self.watch.is_recursive)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 35, in __init__
    self._inotify = Inotify(path, recursive)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 200, in __init__
    self._add_dir_watch(path, recursive, event_mask)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 395, in _add_dir_watch
    self._add_watch(full_path, mask)
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 409, in _add_watch
    Inotify._raise_error()
  File "/home/paolo/Softwares/anaconda3/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 425, in _raise_error
    raise OSError(err, os.strerror(err))
PermissionError: [Errno 13] Permission denied

Versions

  • Spyder version: 4.1.2
  • Python version: 3.7.3
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Linux 4.9.0-12-amd64

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.7.0 (OK)
qtconsole >=4.6.0              :  4.7.2 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.3 (OK)
sphinx >=0.6.6                 :  2.4.4 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  18.1.1 (OK)

# Optional:
cython >=0.21                  :  0.29.15 (OK)
matplotlib >=2.0.0             :  3.1.3 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  1.0.3 (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  1.5.1 (OK)
Projects Duplicate Bug upstream

All 8 comments

To fix this, please open the Anaconda Prompt and run there the following commands:

conda update anaconda
conda install jupyter_client=5.3.4

The solution proposed doesn't solve my problems. The problem is related to the permission of a directory inside the project (in my case, a postgres data docker volume that the spyder user doesn't own). Modifying Inotify._raise_error like this, is sufficent to avoid the exception:

    @staticmethod
    def _raise_error():
        """
        Raises errors for inotify failures.
        """
        err = ctypes.get_errno()
        if err == errno.ENOSPC:
            raise OSError(errno.ENOSPC, "inotify watch limit reached")
        elif err == errno.EMFILE:
            raise OSError(errno.EMFILE, "inotify instance limit reached")
        elif err == errno.EACCES:
            print(err, os.strerror(err))
        else:
            raise OSError(err, os.strerror(err))

dealing with errno.EACCES without raisin the exception is sufficent. However, I don't understand why watching all the files and the directory in a spyder project. Is watching directory like .git or docker data directory necessary? could be possible to avoid watching directory that I can't open?

docker data directory necessary? could be possible to avoid watching directory that I can't open?

This will be added in a future release :-)

@andfoy I think you know well this part of the code. Please work on a fix for this. Thanks!

Ty all for the support!

@bunop, thanks for letting us know the solution for your problem. @andfoy submitted https://github.com/gorakhargosh/watchdog/pull/669 with it, so now it's up to the Watchdog maintainers to merge it.

The new version of watchdog (0.10.3) containing the fix is online :)

Thanks @BoboTiG!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spyder-bot picture spyder-bot  路  3Comments

gabrielclow picture gabrielclow  路  3Comments

hedeqing picture hedeqing  路  3Comments

neilsf1975 picture neilsf1975  路  3Comments

goanpeca picture goanpeca  路  3Comments