teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

修正後のコードを追記

2018/03/08 04:30

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -97,6 +97,16 @@
97
97
  """
98
98
  Return path's uid.
99
99
  ```
100
+ 修正後、import localeは追記してあります。
101
+ ```
102
+ if sys.version_info >= (3,):
103
+ def console_to_str(s):
104
+ # try:
105
+ # return s.decode(sys.__stdout__.encoding)
106
+ # except UnicodeDecodeError:
107
+ # return s.decode('utf_8')
108
+ return s.decode(locale.getpreferredencoding() or "utf-8", 'replace')
109
+ ```
100
110
  ### 試したこと
101
111
 
102
112
  chcpでのUTF8へのへの切り替え

5

追記

2018/03/08 04:30

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -101,6 +101,7 @@
101
101
 
102
102
  chcpでのUTF8へのへの切り替え
103
103
  https://qiita.com/ruteshi_SI_shiteru/items/be6a58276bdbd67dc096
104
+ によるpipの書き直し
104
105
  pipの入れ直し
105
106
  スペースの見直し
106
107
  ### 補足情報(FW/ツールのバージョンなど)

4

ソース追加

2018/03/08 04:24

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -59,6 +59,8 @@
59
59
  ```
60
60
  pip install pysptk
61
61
  ```
62
+ を実行しました。
63
+ 修正したのは、tryから4行をコメントアウトしました。
62
64
  ```
63
65
  if sys.version_info >= (3,):
64
66
  def console_to_str(s):
@@ -71,6 +73,29 @@
71
73
  if isinstance(s, bytes):
72
74
  return s.decode('utf-8', 'replace' if replace else 'strict')
73
75
  return s
76
+
77
+ else:
78
+ def console_to_str(s):
79
+ return s
80
+
81
+ def native_str(s, replace=False):
82
+ # Replace is ignored -- unicode to UTF-8 can't fail
83
+ if isinstance(s, text_type):
84
+ return s.encode('utf-8')
85
+ return s
86
+
87
+
88
+ def total_seconds(td):
89
+ if hasattr(td, "total_seconds"):
90
+ return td.total_seconds()
91
+ else:
92
+ val = td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
93
+ return val / 10 ** 6
94
+
95
+
96
+ def get_path_uid(path):
97
+ """
98
+ Return path's uid.
74
99
  ```
75
100
  ### 試したこと
76
101
 

3

ソースコード追加

2018/03/08 04:08

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -59,7 +59,19 @@
59
59
  ```
60
60
  pip install pysptk
61
61
  ```
62
+ ```
63
+ if sys.version_info >= (3,):
64
+ def console_to_str(s):
65
+ try:
66
+ return s.decode(sys.__stdout__.encoding)
67
+ except UnicodeDecodeError:
68
+ return s.decode('utf_8')
62
69
 
70
+ def native_str(s, replace=False):
71
+ if isinstance(s, bytes):
72
+ return s.decode('utf-8', 'replace' if replace else 'strict')
73
+ return s
74
+ ```
63
75
  ### 試したこと
64
76
 
65
77
  chcpでのUTF8へのへの切り替え

2

実行結果

2018/03/08 04:04

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -40,6 +40,20 @@
40
40
  ----------------------------------------
41
41
  Command "python setup.py egg_info" failed with error code 1 in C:\Users\KHB15\AppData\Local\Temp\pip-build-qtdykif9\pysptk\
42
42
  ```
43
+ スペースやタブを見直したところ以下のエラーになりました。
44
+ ```
45
+ Traceback (most recent call last):
46
+ File "C:\Users\KHB15\Anaconda3\Scripts\pip-script.py", line 6, in <module>
47
+ from pip import main
48
+ File "C:\Users\KHB15\Anaconda3\lib\site-packages\pip\__init__.py", line 26, in <module>
49
+ from pip.utils import get_installed_distributions, get_prog
50
+ File "C:\Users\KHB15\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 22, in <module>
51
+ from pip.compat import console_to_str, expanduser, stdlib_pkgs
52
+ File "C:\Users\KHB15\Anaconda3\lib\site-packages\pip\compat\__init__.py", line 78
53
+ def native_str(s, replace=False):
54
+ ^
55
+ IndentationError: expected an indented block
56
+ ```
43
57
  ### 該当のソースコード
44
58
 
45
59
  ```
@@ -50,7 +64,8 @@
50
64
 
51
65
  chcpでのUTF8へのへの切り替え
52
66
  https://qiita.com/ruteshi_SI_shiteru/items/be6a58276bdbd67dc096
53
-
67
+ pipの入れ直し
68
+ スペースの見直し
54
69
  ### 補足情報(FW/ツールのバージョンなど)
55
70
 
56
71
  Qiitaの指示でエラーが赤字から白地になって減りましたが、インストールはできないです。

1

実行結果

2018/03/08 02:58

投稿

BURI55
BURI55

スコア25

title CHANGED
File without changes
body CHANGED
@@ -18,7 +18,28 @@
18
18
  ^
19
19
  IndentationError: expected an indented block
20
20
  ```
21
+ Pipを更新してみたところ以下のエラーになりました。
22
+ ```
23
+ Collecting pysptk
24
+ Using cached pysptk-0.1.10.tar.gz
25
+ Complete output from command python setup.py egg_info:
26
+ Traceback (most recent call last):
27
+ File "<string>", line 1, in <module>
28
+ File "C:\Users\KHB15\AppData\Local\Temp\pip-build-qtdykif9\pysptk\setup.py", line 25, in <module>
29
+ ['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
30
+ File "C:\Users\KHB15\Anaconda3\lib\subprocess.py", line 316, in check_output
31
+ **kwargs).stdout
32
+ File "C:\Users\KHB15\Anaconda3\lib\subprocess.py", line 383, in run
33
+ with Popen(*popenargs, **kwargs) as process:
34
+ File "C:\Users\KHB15\Anaconda3\lib\subprocess.py", line 676, in __init__
35
+ restore_signals, start_new_session)
36
+ File "C:\Users\KHB15\Anaconda3\lib\subprocess.py", line 957, in _execute_child
37
+ startupinfo)
38
+ FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。
21
39
 
40
+ ----------------------------------------
41
+ Command "python setup.py egg_info" failed with error code 1 in C:\Users\KHB15\AppData\Local\Temp\pip-build-qtdykif9\pysptk\
42
+ ```
22
43
  ### 該当のソースコード
23
44
 
24
45
  ```