質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Unicode

Unicodeはエンコーディングの標準規格です。1つの文字コード体系で多国語の表現を可能にすることを目指して作られています。

UTF-8

UTF-8は8ビット符号単位の文字符号化形式及び文字符号化スキームです。データ交換方式、ファイル形式としては、一般的にUTF-8が使われる傾向があります。

文字コード

文字コードとは、文字や記号をコンピュータ上で使用するために用いられるバイト表現を指します。

コードレビュー

コードレビューは、ソフトウェア開発の一工程で、 ソースコードの検査を行い、開発工程で見過ごされた誤りを検出する事で、 ソフトウェア品質を高めるためのものです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

2055閲覧

pyLDAvisでのunicodeエラー

mkkanvas

総合スコア1

Unicode

Unicodeはエンコーディングの標準規格です。1つの文字コード体系で多国語の表現を可能にすることを目指して作られています。

UTF-8

UTF-8は8ビット符号単位の文字符号化形式及び文字符号化スキームです。データ交換方式、ファイル形式としては、一般的にUTF-8が使われる傾向があります。

文字コード

文字コードとは、文字や記号をコンピュータ上で使用するために用いられるバイト表現を指します。

コードレビュー

コードレビューは、ソフトウェア開発の一工程で、 ソースコードの検査を行い、開発工程で見過ごされた誤りを検出する事で、 ソフトウェア品質を高めるためのものです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/06/08 23:41

前提・実現したいこと

ほかの個所はエラーが出ないのですが、ここだけユニコードエラーが出ます。
コードや入力データはすべてUTF-8で書いています。

発生している問題・エラーメッセージ

UnicodeEncodeError Traceback (most recent call last) <ipython-input-250-7607677e8b6c> in <module> 2 import pyLDAvis.sklearn 3 pyLDAvis.enable_notebook() ----> 4 panel = pyLDAvis.sklearn.prepare(lda, X_tfidf, tv, mds='tsne') 5 panel C:\Users\Public\anaconda3\envs\py37\lib\site-packages\pyLDAvis\sklearn.py in prepare(lda_model, dtm, vectorizer, **kwargs) 93 """ 94 opts = fp.merge(_extract_data(lda_model, dtm, vectorizer), kwargs) ---> 95 return pyLDAvis.prepare(**opts) C:\Users\Public\anaconda3\envs\py37\lib\site-packages\pyLDAvis\_prepare.py in prepare(topic_term_dists, doc_topic_dists, doc_lengths, vocab, term_frequency, R, lambda_step, mds, n_jobs, plot_opts, sort_topics) 396 term_frequency = np.sum(term_topic_freq, axis=0) 397 --> 398 topic_info = _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs) 399 token_table = _token_table(topic_info, term_topic_freq, vocab, term_frequency) 400 topic_coordinates = _topic_coordinates(mds, topic_term_dists, topic_proportion) C:\Users\Public\anaconda3\envs\py37\lib\site-packages\pyLDAvis\_prepare.py in _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs) 252 'Category': 'Topic%d' % new_topic_id}) 253 --> 254 top_terms = pd.concat(Parallel(n_jobs=n_jobs)(delayed(_find_relevance_chunks)(log_ttd, log_lift, R, ls) \ 255 for ls in _job_chunks(lambda_seq, n_jobs))) 256 topic_dfs = map(topic_top_term_df, enumerate(top_terms.T.iterrows(), 1)) C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\parallel.py in __call__(self, iterable) 952 953 if not self._managed_backend: --> 954 n_jobs = self._initialize_backend() 955 else: 956 n_jobs = self._effective_n_jobs() C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\parallel.py in _initialize_backend(self) 719 """Build a process or thread pool and return the number of workers""" 720 try: --> 721 n_jobs = self._backend.configure(n_jobs=self.n_jobs, parallel=self, 722 **self._backend_args) 723 if self.timeout is not None and not self._backend.supports_timeout: C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\_parallel_backends.py in configure(self, n_jobs, parallel, prefer, require, idle_worker_timeout, **memmappingexecutor_args) 490 SequentialBackend(nesting_level=self.nesting_level)) 491 --> 492 self._workers = get_memmapping_executor( 493 n_jobs, timeout=idle_worker_timeout, 494 env=self._prepare_worker_env(n_jobs=n_jobs), C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\executor.py in get_memmapping_executor(n_jobs, **kwargs) 18 19 def get_memmapping_executor(n_jobs, **kwargs): ---> 20 return MemmappingExecutor.get_memmapping_executor(n_jobs, **kwargs) 21 22 C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\executor.py in get_memmapping_executor(cls, n_jobs, timeout, initializer, initargs, env, temp_folder, context_id, **backend_args) 40 _executor_args = executor_args 41 ---> 42 manager = TemporaryResourcesManager(temp_folder) 43 44 # reducers access the temporary folder in which to store temporary C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\_memmapping_reducer.py in __init__(self, temp_folder_root, context_id) 529 # exposes exposes too many low-level details. 530 context_id = uuid4().hex --> 531 self.set_current_context(context_id) 532 533 def set_current_context(self, context_id): C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\_memmapping_reducer.py in set_current_context(self, context_id) 533 def set_current_context(self, context_id): 534 self._current_context_id = context_id --> 535 self.register_new_context(context_id) 536 537 def register_new_context(self, context_id): C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\_memmapping_reducer.py in register_new_context(self, context_id) 558 new_folder_name, self._temp_folder_root 559 ) --> 560 self.register_folder_finalizer(new_folder_path, context_id) 561 self._cached_temp_folders[context_id] = new_folder_path 562 C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\_memmapping_reducer.py in register_folder_finalizer(self, pool_subfolder, context_id) 588 # semaphores and pipes 589 pool_module_name = whichmodule(delete_folder, 'delete_folder') --> 590 resource_tracker.register(pool_subfolder, "folder") 591 592 def _cleanup(): C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py in register(self, name, rtype) 189 '''Register a named resource, and increment its refcount.''' 190 self.ensure_running() --> 191 self._send('REGISTER', name, rtype) 192 193 def unregister(self, name, rtype): C:\Users\Public\anaconda3\envs\py37\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py in _send(self, cmd, name, rtype) 202 203 def _send(self, cmd, name, rtype): --> 204 msg = '{0}:{1}:{2}\n'.format(cmd, name, rtype).encode('ascii') 205 if len(name) > 512: 206 # posix guarantees that writes to a pipe of less than PIPE_BUF UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-19: ordinal not in range(128)

該当のソースコード

python

1import pyLDAvis 2import pyLDAvis.sklearn 3pyLDAvis.enable_notebook() 4panel = pyLDAvis.sklearn.prepare(lda, X_tfidf, tv, mds='tsne') 5panel

試したこと

ここに問題に対して試したことを記載してください。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

quickquip

2020/06/08 23:49

実行しているディレクトリに日本語が入っていたりしますか?
mkkanvas

2020/06/09 00:21

ご回答ありがとうございます。いいえ、入っておりません。
quickquip

2020/06/09 00:33

import tempfile print(tempfile.gettempdir()) の実行結果はどうなりますか?
mkkanvas

2020/06/09 02:10

ありがとうございます。出張のため、明後日となりますが、改めて回答させていただきます。 どうぞよろしくお願いいたします。
guest

回答1

0

自己解決

Macを購入することで解決いたしました

投稿2020/06/13 23:17

mkkanvas

総合スコア1

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問