Background: I encapsulate a package and contain multiple sub packages. Each sub package has multiple different moodles. When I refer to moodles again, it is OK to run in pychar. However, when I put this folder in Linux, there is an error: modulenotfounderror: no module named ‘package’ 。
The structure is as follows:
package:
├─ sub_package0
│ ├─ __init__.py
│ ├─ utils.py
│ └─ www.py
├─ sub_package1
│ ├─ __init__.py
│ ├─ utils1.py
│ └─ www1.py
....
├─ __init__.py
├─ abc.py
└─ xyz.py
After online Baidu, mainly tried two methods:
(1) One is to add environment variable pythonpath in. Bashrc of Linux environment http://blog.sina.com.cn/s/blog_ 9b1b494a0102vrl3.html
(2) In each moudule, add a path through the sys module https://www.cnblogs.com/dreamyu/p/7889959.html
After trying the first method, we found that the above error was still reported, while the second method was too cumbersome because it had to be added to each module. In order to save trouble, put the package directly into anaconda3’s installation path anaconda3/lib/python3.6/site-packages, and the problem is solved. The site packages library is actually the storage location of the package and module installed by PIP install.
Supplementary knowledge
Module: module. A. Py file can be called a module. Using module can avoid the conflict between function name and variable name. Functions and variables with the same name can be stored in different modules, but it should also be noted that the names of built-in functions should not conflict with each other.
Package: package. Different modules are organized by directory, similar to folder. Modules are organized by package to avoid conflicts. After the package is introduced, as long as the top-level package name does not conflict with others, all modules will not conflict with others. Please note that there is a under each package directory__ init__. Py file, this file must exist, otherwise, python will regard this directory as a normal directory instead of a package__ init__. Py can be an empty file or have Python code, because can be an empty file__ init__. Py itself is a module, and its module name is its package name.
div>
Python failed to use PIL writer library. TTF, etc. oserror: cannot open resource
Error information
Read the error information,
return freetype (font),
return freetype font (font, size, index, encoding, layout)_ Oserror: cannot open resource
generally, an error is reported. The reason is that there is a problem in using the resource file
failure reason:
1. First of all, check whether the path you bind is correct. Some people directly bind to the font file in the path of C: (Windows) fonts. This is OK, but you need to use it in Python/
2. If you bind to the font file in the path of C: (Windows) fonts, you can’t use it. Reason: the name of the font may be too long. At this time, we can rename it, Then re install to the path, or directly put your own bound path
3. The bound path is correct, but still an error is reported. Trust the font library to C:// Windows/fonts to see if it is installed. If it is not installed, it may not work
File "./ClothStore/captcha/captcha.py", line 123, in <listcomp>
for size in font_sizes or (65, 70, 75)])
File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 655, in truetype
return freetype(font)
File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 652, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 194, in __init__
font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource
objs/addon/ngx_http_proxy_connect_module-master/ngx_http_proxy_connect_module.o] Error 1
1. This error is due to that nginx was not given NGX before compiling and installing nginx_ http_ proxy_ connect_ The patch of module
executes the following command:
patch – P1 & lt/ usr/local/ngx_ http_ proxy_ connect_ module-master/patch/proxy_ connect.patch
Then compile and install nginx.
[QtRunWork] Error starting process /uic:
My mistake is: after I changed the name of QT, I forgot to change it back here

[C]fatal error: mysql.h: No such file or directory
Environment: under the Linux distribution of windows system, Ubuntu 20.04.2 lts;
Problem Description: MySQL C API programming, after installing MySQL C development library, sudo apt install default libmysqlclient dev , compile version. C file: GCC version. C - O version. O
version. C is as follows:
#include <mysql.h>
#include <stdio.h>
int main(int argc, char **argv)
{
printf("MySQL client version: %s\n", mysql_get_client_info());
exit(0);
}
report errors:
version.c:1:10: fatal error: mysql.h: No such file or directory
1 | #include <mysql.h>
Problem reason: no header file path parameter, unable to address
problem modification: Where is MySQL find mysql. H path: /usr/include/MySQL
recompile: GCC version. C - O version. O - I/usr/include/MySQL
report error again:
/usr/bin/ld: /tmp/ccEn7kBU.o: in function `main':
version.c:(.text+0x14): undefined reference to `mysql_get_client_info'
collect2: error: ld returned 1 exit status
Cause of the problem: no lib parameter is added, so the function cannot be referenced
problem modification: GCC version. C - O version. O - I/usr/include/MySQL - lmysqlclient
problem solving.
ImportError:libta_lib.so.0
The question is like the title
terms of settlement:
Installation through source code compilation
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
Sudo make install
pip install numpy
Find the. So file location and import environment variables
find/-name libta_lib.so.0
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
pytorch raise RuntimeError(‘Error(s) in loading state_dict for {}:\n\t{}‘.format
When training the model, we need to find out whether there is multi GPU training
If using Python to load the model normally:
model.load_state_dict(torch.load(model_path))
If multi GPU training is used in training
model = torch.nn.DataParallel(model, device_ids=range(opt.ngpu))
If so, loading the model requires
model.load_state_dict({k.replace('module.',''):v for k,v in torch.load(model_path).items()})
[go] solve the fatal error of go: concurrent map writes map non concurrent security
Map is not concurrency safe, when there are multiple concurrent growths reading and writing the same map
A panic error occurs
concurrent map writes
For example, this error occurs in the following code:
var mMap map[int]int
func TestMyMap(t *testing.T) {
mMap = make(map[int]int)
for i := 0; i < 5000; i++ {
go func() {
mMap[i] = i
}()
go readMap(i)
}
}
func readMap(i int) int {
return mMap[i]
}
There are many ways to solve this problem. Now we use read-write lock,
Concurrent access to map is not safe, and undefined behavior will appear, leading to program exit. Therefore, if you want to access the map concurrently in multiple coroutines, you must provide some synchronization mechanism. Generally, you can control the concurrent access to the map by reading and writing the lock sync.rwmutex. Encapsulating the map and sync.rwmutex can realize the secure concurrent access to the map
Code after transformation
type SMap struct {
sync.RWMutex
Map map[int]int
}
func (l *SMap) readMap(key int) (int, bool) {
l.RLock()
value, ok := l.Map[key]
l.RUnlock()
return value, ok
}
func (l *SMap) writeMap(key int, value int) {
l.Lock()
l.Map[key] = value
l.Unlock()
}
var mMap *SMap
func TestMyMap(t *testing.T) {
mMap = &SMap{
Map: make(map[int]int),
}
for i := 0; i < 5000; i++ {
go func() {
mMap.writeMap(i, i)
}()
go readMap(i)
}
}
func readMap(i int) (int, bool) {
return mMap.readMap(i)
}
There are three ways:
1. Use channel
2. Use sync. Map
3. Use map but lock it
Error handling response: Error: Syntax error, unrecognized expression: .c-container /deep/ .c-contai
The following error message appears on the browser console:
Error handling response: Error: Syntax error, unrecognized expression: .c-container /deep/ .c-container
at Function.se.error ()
at se.tokenize ()
at se.select ()
at Function.se [as find] ()
at S.fn.init.find ()
at new S.fn.init ()
...
After checking, it is found that the plug-in affects the global
$. After deleting the plug-in in the browser (you need to confirm which plug-in it is), you can solve the error
Resolution of problems with rviz global status displayed as error
Resolution of problems with rviz global status displayed as error
Run the program rosrun rviz rviz – D in the official tutorial of ROS
rospack find turtle_ tf/rviz/turtle_ rviz.rviz
No coordinates are displayed for the results found

Later, I run rosrun rviz when I write TF transformation, and find that the status of TF is warning when add joins TF

In fact, first of all, change the map on the left side of the fixed frame under global options in the upper left corner to world, and then the global status will become OK.
Then select add in the lower left corner to add a TF display. So you can see that there are three coordinates in the middle three-dimensional diagram. Two of them are the coordinates of the two turtles, and the one in the middle is the world coordinates. Next, move the tortoise, and the two coordinates will follow.
Understand the nature of the displays on the left in rviz. In fact, those things are the same as a model. When a tortoise is represented by a coordinate system, the coordinate system will change accordingly. How do you know about this change?In frame, it will receive the corresponding message and then make corresponding actions according to the message.
The exact reason is still unknown
Solve the problem of “error empty block statement no empty” in the console (Vue project)
Solve the problem of “error empty block statement no empty” in the console (Vue project)
This problem is caused by the code space in the page, and the specific reason is the eslint verification
Solution
The first step is to add in package. JSON
{
"name": "system",
"version": "0.1.0",
"private": true,
"eslintConfig": {
"plugins": ["example"],
"env": {
"example/custom": true
}
},
}
The second step is to add an independent configuration file. Eslintrc. JS in the root directory of the project
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ?'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ?'warn' : 'off'
}
}
The third step is to create vue.config.js in the project root directory
module.exports = {
devServer: {
overlay: {
warnings: false,
errors: false
}
}
}
When writing a website, Vue + Flash prompts network error when visiting Vue page
Flash page is mounted at 127.0.0.1:8010
Vue page is mounted at 127.0.0.1:8080 (Axios. Defaults. Baseurl)=‘ http://127.0.0.1 :8010’)
After running, you can access port 8010, but when you access port 8080, you will be prompted with network error, and the security group port will be set to
after checking, it is found that port 8010 is forward to port 1527
guess that port 8010 is occupied
after a look, it is really
so you can directly modify the page port in app.py to 5000,
axios.defaults.baseURL = ‘ http://127.0.0.1 : 5000 ‘(or other non conflicting ports)
This time, you can directly access port 8080
it is found that using ‘127.0.0.1’ can still achieve public network page projection, but only using ‘0.0.0.0’ for flash