0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OSX上でPyCharmをつかってxlwingsを実行するとCommand failed: The user has declined permission. (-1743)エラーになる場合の対応策

Last updated at Posted at 2021-08-09

現象

PyCharmでxlwingsのプログラムを書こうとすると、以下のエラーが出る。

Command failed: The user has declined permission. (-1743)

実行しようとするコードは以下の通り

# !/usr/local/bin/python3.9
# -*- coding: utf-8

import xlwings as xw

wb = xw.Book('myexcel.xlsx')

同じプログラムをターミナルから実行すると問題なく動作した。
どうやらPyCharmにOSXのパーミッションが足りないようだ。

この記事を参考にした。
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005152379-Pycharm-cannot-get-permission-to-control-Excel-Mac-

対応方法

PyCharmをターミナルから起動する。

ターミナルを開いて、以下を実行してPyCharmを起動する。このとき他にPyCharmが起動していればて終了させる。

/Applications/PyCharm.app/Contents/MacOS/pycharm

エラーが発生しなくなった。

毎回長いコマンドを入力するのは面倒なので .bashrc に alias を定義。

alias pc='/Applications/PyCharm.app/Contents/MacOS/pycharm'

コマンドラインから pc を入力すると PyCharm が起動するようになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?