I can't use Japanese with pyperclip

I can't use Japanese with pyperclip

I'm reading "Let python do the boring things". Among them, there is a sample program that uses pyperclip, but when I use Japanese, it did not work with an error. The error was something like the following. (I'm sorry, I don't remember the last one) 「UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: ~~~~」

Cause

--Using python2.7 --Run python in VS Code

It was the above two points. Looking at issues on the original site, does Chinese support? It was reported that it did not work in Chinese. However, it was also reported that "If you specify utf-8 encoding, it will work ~", and it worked in my environment as well. However, another person reported that "it works even if you do not specify the encoding". In my environment, it doesn't work unless I specify the encoding ... why! !!

Investigation

import sys
print('defaultencoding:', sys.getdefaultencoding())

Investigate which encoding is specified in the above code! As a result, "ascii"! why! !! Put in python3 and let it run on python3! !! I ran it with VS Code's task runner, so when I looked at which command I was running ... the letters "python"! Not python3! !! Change to python3 and investigate the default encoding again! The letters "utf-8"! Run pyperclip! Fall with the same error! !! I thought it was bad to run it with VS Code, so run it in the terminal! I was able to do it safely! !!

So I identified the cause. I don't know why it can't be executed with VS Code. .. .. I've just started studying python, so please point out anything strange!

** 2017/06/29: Addendum ** VS Code is the cause of the error, but it seems that VS Code has converted to ascii. github When I looked at it, there were a lot of issues. The solution presented by the developer is to add the sentence "" runner ":" terminal "" to "task.json". The point is that if you run it in the terminal, you won't get an error, so you should run it in the terminal. In my environment, the task no longer causes an error when running python. I wonder if it can't be fixed ...?

Recommended Posts

I can't use Japanese with pyperclip
I can't search with # google-map. ..
I can't download images with Google_images_download
I can't install mysql-connector-python with anaconda
How to use Japanese with NLTK plot
I can't deploy with google app engine
I can't install the package with pip.
I can't see new files with yum
Japanese with matplotlib
I can't install Dask with pip on Ubuntu
I tried to use lightGBM, xgboost with Boruta
I want to use MATLAB feval with python
I want to use Temporary Directory with Python2
I don't want to use -inf with np.log
I want to use ip vrf with SONiC
Use mecab-ipadic-neologd with igo-python
Use RTX 3090 with PyTorch
Use pipdeptree with virtualenv
[Python] Use JSON with Python
Use indicator with pd.merge
String manipulation with python & pandas that I often use
I played with wordcloud!
Japanese input with pyautogui
Use mecab with Python3
Use tensorboard with Chainer
Use pip with MSYS2
I can't install Anaconda!
Use Python 3.8 with Anaconda
Use pyright with Spacemacs
Use python with docker
Use TypeScript with django-compressor
Use LESS with Django
[Note] I can't connect with wget, but I can connect with curl
I can't manipulate iframes in a page with Selenium
Use MySQL with Django
I can't exe a project using PyWebView with PyInstaller
Use Enums with SQLAlchemy
Use tensorboard with NNabla
Use GPS with Edison
I can't use the darknet command in Google Colaboratory!
Use nim with Jupyter
I want to use R functions easily with ipython notebook
I wrote the code for Japanese sentence generation with DeZero
Why can I use the module by importing with python?
I tried various methods to send Japanese mail with Python
I want to change the Japanese flag to the Palau flag with Numpy
[Python] I want to use the -h option with argparse
I want to use a virtual environment with jupyter notebook!
I can't log in to the admin page with Django3
I tried to translate English subtitles into Japanese with Udemy
I tried fp-growth with python
I tried scraping with Python
Use Trello API with python
I wrote GP with numpy
Use shared memory with shared libraries
Send Japanese email with Python3
Use "$ in" operator with mongo-go-driver
Use custom tags with PyYAML
I wrote python in Japanese
Use directional graphs with networkx
Use TensorFlow with Intellij IDEA