質問編集履歴

2

エラーが出たときの対処

2018/09/30 11:54

投稿

Yukiya025
Yukiya025

スコア86

test CHANGED
File without changes
test CHANGED
@@ -67,3 +67,37 @@
67
67
  lat...")
68
68
 
69
69
  ```
70
+
71
+
72
+
73
+ ## `$ python setup.py install`でエラーが出る場合は
74
+
75
+ Anacondaでは、上記のやり方でスムーズに行ったのですが、Linux Mint上のPycharmでは`[Errno 13] Permission denied:`が出ました。
76
+
77
+
78
+
79
+ そのときは以下をPycharmのTerminalに入力してください。
80
+
81
+ ```
82
+
83
+ $ whereis python
84
+
85
+ $ sudo /usr/bin/python3.6 setup.py install
86
+
87
+ ```
88
+
89
+ **実際の画像**
90
+
91
+ ![RealWindow](ee07a0510d3d42aebf177d56ea7213bf.png)
92
+
93
+ 私の場合は`$ whereis python`でpythonのあるディレクトリがずらずらと出てきていますが、使っているのは一番最初の`/usr/bin/python3.6`なので、これを使って次のコマンドを打ちます。
94
+
95
+
96
+
97
+ ```
98
+
99
+ sudo /usr/bin/python3.6 setup.py install
100
+
101
+ ```
102
+
103
+ 参考サイト: [stackoverflow](https://stackoverflow.com/questions/22551461/how-to-avoid-permission-denied-while-installing-package-for-python-without-sudo)

1

完成ファイル追記

2018/09/30 11:54

投稿

Yukiya025
Yukiya025

スコア86

test CHANGED
File without changes
test CHANGED
@@ -13,3 +13,57 @@
13
13
 
14
14
 
15
15
  上記のライブラリを試しましたが、サービスを終了しているか、ロシア語に対応していないかのどちらかで使えません(T-T) ほかに使えるものはあるでしょうかorz
16
+
17
+
18
+
19
+ # できましたー(≧∀≦)
20
+
21
+ [CHERRY](https://teratail.com/users/CHERRY)様の助言で[googletrans 2.3.0](https://pypi.org/project/googletrans/)を採用し、`AttributeError: 'NoneType' object has no attribute 'group'` を検索にかけて、前より辛抱強く探して[stackoverflow](https://tinyurl.com/ycwmfba5) の解決策を見つけました!
22
+
23
+ > そのまま使うと動かないからパッチ当ててね! 以下のコマンド実行してね! まずはアンインストールからね!
24
+
25
+
26
+
27
+ ```
28
+
29
+ $ pip uninstall googletrans
30
+
31
+ $ git clone https://github.com/BoseCorp/py-googletrans.git
32
+
33
+ $ cd ./py-googletrans
34
+
35
+ $ python setup.py install
36
+
37
+ ```
38
+
39
+ これだけです。`$ python setup.py install`の後に改めて`$ pip install googletrans`する必要はありません。
40
+
41
+
42
+
43
+ # `.py`ファイルのコードと実行結果
44
+
45
+ **`.py`ファイル**
46
+
47
+ ```python
48
+
49
+ from googletrans import Translator
50
+
51
+
52
+
53
+ translator = Translator()
54
+
55
+ print(translator.translate('солдат', 'ja'))
56
+
57
+ ```
58
+
59
+
60
+
61
+ **実行結果**
62
+
63
+ ```
64
+
65
+ Translated(src=ru, dest=ja, text=兵士, pronunciation=Heishi, extra_data="{'trans
66
+
67
+ lat...")
68
+
69
+ ```