Category: TroubleShooting

Why does category list return “Uncategorized”?

Problem

I’d like to display the list of all categories in my theme, but it return “Uncategorized”. The PHP code in index,php is as below.

<h1>Categories</h1>
<?php
	$categories = get_the_category();
	if ( $categories ) {
		foreach( $categories as $category ) {
			$output .= '<a href="' . get_category_link($category->term_id) 
			. '">' . $category->cat_name . '</a>' . ' ';
		}
		echo $output;
	}
?>

The result is the following.

The cause of this problem

get_the_category(); is the function to get the categories of “current” post or page. This page is index.php with no category, so it return “Uncategorized”.

Solution

Use get_categories(); instead of get_the_category();.

<h1>Categories</h1>
<?php
	$categories = get_categories();
	if ( $categories ) {
		foreach( $categories as $category ) {
			$output .= '<a href="' . get_category_link($category->term_id) 
				. '">' . $category->cat_name . '</a>' . ' ';
		}
	echo $output;
	}
?>

This is the result.

[Error]’unicodeescape’ codec can’t decode bytes

Problem

When I run the python code below, the error “SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3” occurred.

import glob
import os

word = "single_post_title"
path = "C:\Users\USERNAME\Downloads\document"
files = glob.glob(path +'\**')
for f in files:
    print(f)

Environment

Windows10
Python 3.8.6

Cause of the error

The unicodeescape ‘\’ is used in path = “C:\Users\USERNAME\Downloads\document”. “\” is used as a part of escape sequences in Windows system.

Solution

Solution 1. Use “\\” to express “\” in string data

path = "C:\\Users\\USERNAME\\Downloads\\document"
files = glob.glob(path +'\\**')

Solution 2. Use “/” instead of “\”

path = "C:/Users/USERNAME/Downloads/document"
files = glob.glob(path +'/**')

Error with xampp-control.ini in quitting XAMPP

Problem

When I quit XAMPP, an error “Control Panel, an Error: Cannot create file “…\xampp\xampp-control.ini” occured.

And the message “Application Error (Not Responding)” displayed.

Environment

Windows10
XAMPP 7.4.10

What is xampp-control.ini?

If you’d like to know what XAMPP is, please refer the article “Installation of XAMPP“. xampp-control.ini is the configuration settings of XAMPP. It contains variables and values as below.

[Common]
Edition=
Editor=notepad.exe
Browser=
Debug=0
Debuglevel=0
TomcatVisible=1
Language=English
[EnableModules]
Apache=1
MySQL=1
FileZilla=1
Mercury=1
Tomcat=1

What is the meaning of error message?

The error message says “the access to xampp-control.ini was denied” and “the access violation occurred in the module xampp-control.exe”.

Cause of the error

Current user is unauthorized to the file “xampp-control.ini”.

Solution

Change the current user to the administrator

Run “xampp-control.exe” as a administrator. This is the best way.

Appendix

Another Solution: Change permission of xampp-control.ini

Right-click “xampp-control.ini” and open property.

Open Security tab and click “Edit” button to change the permission. Add current user and change its permission from “Read” to “Modify”. Refer ‘“Windows cannot access the specified device, path, or file” error when you try to install, update or start a program or file‘ for details.

Warning: Be careful that this may cause security vulnerability. In my case, I run this application in only local environment.

[error]No such file or directory (header file)

Error Detail

When I compile c++ file using g++ command as below, the fatal error: numpy/arrayobject.h: No such file or directory occurred.

>g++ filename.cpp -std=c++11 -IC:\Python27\include -lpython2.7
In file included from filename.cpp:1:
../libs/matplotlibcpp.h:17:12: fatal error: numpy/arrayobject.h: No such file or directory
   17 | #  include <numpy/arrayobject.h>

matplotlibcpp.h in the source code is c++ header file to plot a graph.

numpy/arrayobject.h is in the directory C:\Python27\Lib\site-packages\numpy\core\include\numpy.

Cause

The compiler could not find arrayobject.h because that file is not included in the include search path.

Solution

Add the path to arrayobject.h using -I command line option as follows.

>g++ filename.cpp -std=c++11 -IC:\Python27\include -lpython2.7 -IC:\Python27\Lib\site-packages\numpy\core\include

homebrew install Error

Problem

An error “Permission denied @ apply2files – /usr/local/share/ghostscript/9.23/Resource/CIDFSubst/Deng.ttf” occurred when I tried to update homebrew.

What is homebrew?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)

What is ghostscript?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)
Ghostscript is invoked and started by other software including homebrew.

The Resource / CIDFSubst directory is a directory to store TrueType fonts (but there is no problem here).

Cause of the error

Because the error message says “Permission denied”, the current user does not have access. So it seems that homebrew cannot use the required files.

Solution

As an immediate solution, give access to the ghostscript directory with the following command. You will be prompted for a password.

sudo chown -R <UserName>:admin /usr/local/share/ghostscript

Now you can run without error. It remains unclear why the access was lost.

[error]error MSB8020: The build tools for v140 (Platform Toolset = ‘v140’) cannot be found.

Error Detail

error MSB8020: The build tools for v140 (Platform Toolset = ‘v140’) cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting “Retarget solution”.

Cause

The required version of build tool for building solution is different from the version of build tool on your environment.

Checklist

Retarget the solution. Right click on the solution and click the “Retarget solution”. Select the version of build tool required.

[error]fatal error C1181: cannot open input file ‘~~.lib’

Error Detail

fatal error C1181: cannot open input file ‘~~.lib

Cause

Visual Studio can’t find library named ‘~~.lib’

Checklist

File name

There is truly no library with such a name because of misspelling or missing in file path.

Additional Library Directories

Visual Studio can’t read the directory where ‘~~.lib’ is in. Check the include file. Open properties of the project and check “Additional Library Directories”.

Right click the project name on Solution explorer and open Properties.

Add the directory that contains the library into Linker > General >Additional Library Directories”.

Configuration

If the target directory already exists in Additional Library Directories list, check Configuration and the build environment. If they are different, change the configuration and add the library to Additional Library Directories again.

[error]fatal error C1083: Cannot open include file: ‘~~’: No such file or directory

Error Detail

Cannot open include file: ‘<FILE_NAME>’: No such file or directory

Cause

Visual Studio can’t find the include file named FILE_NAME.

Checklist

File name

There is truly no file with such a name because of misspelling, mistake for file extension or missing in file path. Compare the name and path of the include file to your code.

Additional Include Directories

Visual Studio can’t read the directory where FILE_NAME is in. Check the include file. Open properties of the project and check “Additional Include Directories”.

Right click the project name on Solution explorer and open Properties.

Add the directory that contains the include file into C/C++ >Additional Include Directories”.

Configuration

If the target directory already exists in Additional Include Directories list, check Configuration and the build environment. If they are different, change the configuration and add the include folder to Additional Include Directories again.