jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 261 forks source link

Windows 10: [Errno 13] Permission denied #1768

Open arqeco opened 4 years ago

arqeco commented 4 years ago

Hello,

I am having this error opening a .py file or using M-X elpy-config:

Running 'c:/WINDOWS/py.exe -m venv c:/Users/Márcio/AppData/Roaming/.emacs.d/elpy/rpc-venv':

Error: [Errno 13] Permission denied: 'c:\Users\Márcio\AppData\Roaming\.emacs.d\elpy\rpc-venv\pyvenv.cfg'

Elpy failed to install its dedicated virtualenv due to the above error. If the error details does not help you fixing it, You can report this problem on Elpy repository on github. In the meantime, setting the elpy-rpc-virtualenv-path' option to eitherglobal' or `current' should temporarily fix the issue.

Windows 10 Home. Version 1903.

GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)

elpy is installed with this init.el:

(require 'package)

(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)

(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar myPackages
  '(elpy                            ;; Emacs Lisp Python environment
    flycheck                        ;; On the fly syntax checking
    material-theme                  ;; Theme
    dracula-theme
    green-phosphor-theme
    blacken
    smart-mode-line
    magit
    try
    )
  )

(mapc #'(lambda (package)
          (unless (package-installed-p package)
            (package-install package)))
      myPackages)

(elpy-enable)
galaunay commented 4 years ago

Elpy is trying to build a virtualenv to install the dependencies it needs.

Apparently it fails to write a file in the folder named c:\Users\Márcio\AppData\Roaming\.emacs.d\elpy\rpc-venv Does this folder exist on your installation ?

If it does, is there a file named pyvenv.cfg already there ?

arqeco commented 4 years ago

After removing all other packages except elpy from myPackages list in init.el, removing all folders from .emacs.d and starting emacs again, the error changes to this when opening an .py file

Output from Backend

There was some unexpected output from the Elpy backend. This is usually not a problem and should usually not be reported as a bug with Elpy. You can safely hide this buffer and ignore it. You can also see the output below in case there is an actual problem.

Output c:\Users\Márcio\AppData\Roaming.emacs.d\elpy\rpc-venv\Scripts\python.exe: Error while finding module specification for 'elpy.main' (ModuleNotFoundError: No module named 'elpy')

Please notice that my user name have an accent. It's Márcio. But the above output shows c:\Users\Márcio.

Now, at least I can use M-X elpy-config. But, despite what is written below, pip is installed on RPC virtualenv.

Elpy Configuration

Emacs.............: 26.3
Elpy..............: Not found (Python), 1.33.0 (Emacs Lisp)
Virtualenv........: venv (d:/teste-emacs/venv/)
Interactive Python: python 3.7.6 (d:/teste-emacs/venv/Scripts/python.exe)
RPC virtualenv....: rpc-venv (c:/Users/Márcio/AppData/Roaming/.emacs.d/elpy/rpc-venv)
 Python...........: c:/WINDOWS/py.exe 3.7.6 (c:/WINDOWS/py.exe)
 Jedi.............: Not found (0.16.0 available)
 Rope.............: Not found (0.16.0 available)
 Autopep8.........: Not found (1.5 available)
 Yapf.............: Not found (0.29.0 available)
 Black............: Not found (19.10b0 available)
Syntax checker....: Not found (flake8)

Warnings

The Python interpreter could not find the elpy module. Please report
to: https://github.com/jorgenschaefer/elpy/issues/new.

Pip doesn't seem to be installed in the dedicated virtualenv created
by Elpy (c:/Users/Márcio/AppData/Roaming/.emacs.d/elpy/rpc-venv). This
may prevent some features from working properly (completion,
documentation, reformatting, ...). You can try reinstalling the
virtualenv. If the problem persists, please report on Elpy's github
page.

[Reinstall RPC virtualenv]

The jedi package is not available. Completion and code navigation will
not work.

[Install jedi]

The autopep8 package is not available. Commands using this will not
work.

[Install autopep8]

The yapf package is not available. Commands using this will not work.

[Install yapf]

The black package is not available. Commands using this will not work.

[Install black]

The configured syntax checker could not be found. Elpy uses this
program to provide syntax checks of your programs, so you might want
to install one. Elpy by default uses flake8.

[Install flake8]
arqeco commented 4 years ago

galaunay,

Yes this file exists.

(rpc-venv) C:\Users\Márcio\AppData\Roaming\.emacs.d\elpy\rpc-venv>type pyvenv.cfg
home = C:\Python37
include-system-site-packages = false
version = 3.7.6
galaunay commented 4 years ago

Ok, so that's another issue. Probably related to #1757.

In #1757, the faulty function seemed to be elpy-rpc--environment. If you run the following snippets, it should display some lines in your *Messages* buffer:

(defun elpy-rpc--environment ()
  "Return a `process-environment' for the RPC process.

This includes `elpy-rpc-pythonpath' in the PYTHONPATH, if set."
  (message "\n\n=== DEBUG 'elpy-rpc--environment ===\n")
  (message "elpy-rpc-pythonpath: %s" elpy-rpc-pythonpath)
  (message "elpy-rpc-pythonpath-fromelpy: %s" (file-name-directory (locate-library "elpy")))
  (message "__init__.py: %s" (expand-file-name "elpy/__init__.py"
                                                elpy-rpc-pythonpath))
  (message "__init__.py exists ?: %s" (file-exists-p (expand-file-name
                                                      "elpy/__init__.py"
                                                      elpy-rpc-pythonpath)))
  (if (or (not elpy-rpc-pythonpath)
          (not (file-exists-p (expand-file-name "elpy/__init__.py"
                                                elpy-rpc-pythonpath))))
      process-environment
    (let* ((old-pythonpath (getenv "PYTHONPATH"))
           (new-pythonpath (if old-pythonpath
                               (concat elpy-rpc-pythonpath
                                       path-separator
                                       old-pythonpath)
                             elpy-rpc-pythonpath)))
      (message "old-pythonpath: %s" old-pythonpath)
      (message "new-pythonpath: %s" new-pythonpath)
      (cons (concat "PYTHONPATH=" new-pythonpath)
            (append process-environment
                    (when (and (string-equal system-type "windows-nt")
                               (>= (string-match-p
                                    (regexp-quote "utf-8")
                                    (format "%s" buffer-file-coding-system))) 0)
                      (list
                       "PYTHONIOENCODING=utf-8"
                       "PYTHONLEGACYWINDOWSSTDIO=1")))))))
(message "%s" (elpy-rpc--environment))

It may help to understand what is happening wrong.