Category: TroubleShooting

Rotate and Scale Don’t Work in Blender

This is trouble shooting.

Problem

I couldn’t resize or rotate widget in Blender.

example) expanding box in the x-axis direction

Environment

Blender 2.83
Windows 10

Check List

Affect Only check box

If the Options > Affect Only > Locations checkbox is on, check it off.

Transform is rocked

If the Rotation and Scale are rocked, the arrows to resize or rotate are not displayed.

How To Use Keymap Preference in Blender

The system of keymap preference in Blender is complex a little.

GOAL

Today’s goal is to summarize how to customize keymaps in Blender. The main contents are how to change keymaps, save and import/export key configuration presets. This article doesn’t contain how to use keymap editor or details of UI.

Environment

Blender 2.83 (Python 3.7.4)
Windows 10

What is keymap preference?

The following is an excerpt from the Blender manual.

The keymap editor lets you adjust your keymap via:

Presets: Predefined keymaps which come with Blender and can be added to.
Preferences: Keymaps may define their own preferences to change the functionality or add additional key bindings.
Key Map Items: You may add/remove/edit individual keymap entries.

from “Keymap” in Blender 2.92 Manual

How to change keymap

Keymaps can be changed in each keymap editor.

(more…)

[AttributeError] module ‘tensorflow’ has no attribute ‘Session’

When I was trying the exercise of TensorFlow Programming Concepts, an error “AttributeError module ‘tensorflow’ has no attribute ‘Session'” occurred.

Error Detail

The code run in Google Colaboratory is the following.Generic HighlightingEnlighterJS Syntax Highlighter

This image has an empty alt attribute; its file name is 38dbab30e4232a9115cd0f972a88d428.png
An attribute error

Cause

tf.Session can be used in tensorflow 1.x version, while it cannot be used in 2.x version.

(more…)

[error]CreateProcess error=2, The system cannot find the file specified in PyCharm

Error Detail

When I try to run python in PyCharm. The error occurred as below. What is venv\Scripts\python.exe?

Error running 'easy_keymaps_ui': Cannot run program "C:\Users\<USER_NAME>\source\test\venv\Scripts\python.exe" (in directory "C:\Users\<USER_NAME>\source\test"): CreateProcess error=2, The system cannot find the file specified

Environment

Windows 10
PyCharm 2020.3
Python 3.8

Cause

The python specified to use as interpreter in PyCharm cannot be found. In my case, the specified python is python that is bundled to the deleted virtual env of PyCharm project.
Check “Configure a virtual environment” for details about virtual env of PyCharm.

Solution

Change the python to use

Right click the program to run. And click “Modify Run Configuratuib…”

Select valid interpreter and click ”OK”.

How to remove and add python interpreters to the project

Open “File > Settings > Python Interpreter”. Click the gear icon and click “Show All” button.

Click “-” button to delete invalid Python.

And click “+” button to add new valid python to use to run python program. I selected my local system python.

[Error]pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool

Error Detail

When I install PySide2 with pip command, the error below occurred. There are 2 exceptions “socket.timeout: The read operation timed out” and “pip._vendor.urllib3.exceptions.ReadTimeoutError“.

<!–more–>

>pip install pyside2
Collecting pyside2
  Downloading PySide2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win_amd64.whl (136.3 MB)
     |██████████████████              | 75.3 MB 25 kB/s eta 0:40:29ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
.
.
. Omitted
.
.
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
    status = self.run(options, args)
.
.
. Omitted
.
.
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

Environment

Windows 10
Pyhon 3.8.7
pip 20.2.3

Cause

When response couldn’t gotten in time, both of exceptions are occurred. The time is defined by environment variable “PIP_DEFAULT_TIMEOUT”.

The cause is just a poor connection in my case.

Solution

Change the value of PIP_DEFAULT_TIMEOUT (the value is an integer in seconds).
Reference : “Environment Variables” from pip documentation

Method 1. Pass the option to pip directly

pip --default-timeout=1200 install pyside2

Method 2. Set the default value

set PIP_DEFAULT_TIMEOUT=1200

[Tips] How to fit p content in the parent box.

Problem

In HTML, some URL or long sentence sticks out of the parent box. The following is an example.

<div class="box">
	<p>This is an example of short message</p>
</div>
<br/>
<div class="box">
	<p>ThisIsAnExampleOfLongMessage</p>
</div>
.box{
	width:120px;
	border: 2px solid #111;
}

Result

The cause of this problem

This is because of the settings of word-break or overflow-wrap (or word-wrap). Define word break point by word-break css property or define when the browser should insert line breaks within an otherwise unbreakable string.

Reference: word-break, overflow-wrap

Solution

Solution1. Set “word-break” break-word

.box{
	width:120px;
	border: 2px solid #111;
	word-break: break-word;
}

Solution2. Set “overflow-wrap” break-word

.box{
	width:120px;
	border: 2px solid #111;
	overflow-wrap: break-word;
}

Result

[Tips]Why command “sleep 1m” doesn’t work in mac

Problem

In my shell script, “sleep 1m” command doesn’t wait 1 minutes but 1 second.

sleep.sh

#!/bin/sh
echo "start timer"
sleep 1m
echo "stop"

Environment

macOS Catalina 10.15.5

The cause of this problem

In Mac OS X, sleep command doesn’t work with quantifiers and takes argument num just as num seconds.

Reference: OSX bash “sleep”, Mac OS X Man Pages

Solution

Use 60 times minutes.

sleep.sh

#!/bin/sh
echo "start timer"
sleep 1*60
echo "stop"

How To Recover From An Error Caused By Plugin

I could neither open nor edit a post in WordPress. The error “Uncaught (in promise) TypeError: Cannot read property ‘replace’ of undefined” occurred.

Problem

I created a post with “Enlighter Sourcecode” block by using Enlighter plugin and save the post. When I opened the saved post, the error “Uncaught (in promise) TypeError: Cannot read property ‘replace’ of undefined” occurred and nothing was displayed.

Environment

WordPress 5.5.3
Enlighter – Customizable Syntax Highlighter 4.4.1

The cause of this problem

Reference: Unable to edit posts when EnlighterJs is enabled

The block is somehow corrupted.

Solution

1. Deactivate the plugin at issue.

2. Open the post in edit mode and copy all contents.

3. Activate the plugin again. And create new post and paste it.

UnicodeDecodeError: ‘cp932’ codec can’t decode byte 0x99 in position ~ : illegal multibyte sequence

Problem

When I open the file in Python, the error “UnicodeDecodeError: ‘cp932’ codec can’t decode byte 0x99 in position ~ : illegal multibyte sequence” occurred.

The code is as below.

path = 'wordpress/wp-admin/about.php'

with open(path) as f:
            lines = f.readlines()
            print(lines)

Environment

Windows 10
Python 3.8.6

The cause of this problem

The character code ‘cp932’ is Microsoft Cade page 932(Shift_JIS). And ‘0x99’ is the number of 1byte represented by hexadecimal. This error occurs when the character code used for decoding the file does not match the character code of the file.

Solution

Solution 1. Use encoding option argument

If you know the coding of the file, you can specify it with option argument of open() function.

with open(path, encoding = "utf_8") as f:
    lines = f.readlines()
    print(lines)

Solution 2. Use try and except

If you’d like to use a few character coding and ignore files of other character coding.

try:
    with open(path, encoding = "shift_jis") as f:
        lines = f.readlines()
        print(lines)
except:
    pass
try:
    with open(path, encoding = "ascii") as f:
        lines = f.readlines()
        print(lines)
except:
    pass
try:
    with open(path, encoding = "utf_8") as f:
        lines = f.readlines()
        print(lines)
except:
    pass

Solution 3. Use chardet

Chardet is a module to detect the character encoding.

Install chardet with pip command.

> pip install chardet

Installing collected packages: chardet
....
Successfully installed chardet-3.0.4

You can get the character encoding by chardet.dect(<binary data>).

import chardet
path = 'wordpress/wp-admin/about.php'

with open(path, mode='rb') as f:
    binary = f.read()
    code = chardet.detect(binary)['encoding']
with open(path, encoding=code) as f:
    lines = f.readlines()
    print(lines)

Solution 4. Ignore errors by codec

You can ignore errors by using codec.open() and setting the option argument ‘errors’ ‘ignore’.

import codec
path = 'wordpress/wp-admin/about.php'

with codecs.open(path, 'r', 'utf-8', 'ignore') as f:
    lines = f.readlines()
    print(lines)