Here is a simple method to solve the error: module ‘networkx’ has no attribute ‘from_pandas_dataframe’
Use networkx.rom_pandas_dataframe() to report an error:
Correction: use networkx.from_pandas_edgelist
Author Archives: Robins
Module build failed: Error: Couldn’t find preset “es2015” relative to directory
1. Error description
F:\WebstormProjects\euw\esa>npm install babel-plugin-component -D
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"dar
+ [email protected]
added 4 packages from 3 contributors in 13.118s
F:\WebstormProjects\euw\esa>npm run dev
> [email protected] dev F:\WebstormProjects\euw\esa
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
94% asset optimization
ERROR Failed to compile with 2 errors 16:10:44
error in (webpack)-dev-server/client?http://localhost:8081
Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\\WebstormProjects\\euw\\esa"
at F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
at Array.map ()
at OptionManager.resolvePresets (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (F:\WebstormProjects\euw\esa\node_modules\babel-loader\lib\index.js:50:20)
at Object.module.exports (F:\WebstormProjects\euw\esa\node_modules\babel-loader\lib\index.js:173:20)
@ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js
error in ./src/main.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\\WebstormProjects\\euw\\esa"
at F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
at Array.map ()
at OptionManager.resolvePresets (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (F:\WebstormProjects\euw\esa\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (F:\WebstormProjects\euw\esa\node_modules\babel-loader\lib\index.js:50:20)
at Object.module.exports (F:\WebstormProjects\euw\esa\node_modules\babel-loader\lib\index.js:173:20)
@ multi (webpack)-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./src/main.js
2. The reason for the error
The contents of the .babelrc file
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}
To
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
3. Solution
Execute the following command:
npm install --save-dev babel-preset-es2015
F:\WebstormProjects\euw\esa>npm install --save-dev babel-preset-es2015
npm WARN deprecated [email protected]: ???? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected]
added 1 package from 1 contributor in 9.707s
F:\WebstormProjects\euw\esa>
android mediaplayer went away with unhandled event after the recording stopped
Like the title, when this happens, you need to reset it before release.
mediaPlayer.reset();
mediaPlayer.release();
Error in Tensorflow using variables: List of Tensors when single Tensor expected
1. Background:
import tensorflow as tf
a = tf.constant(tf.random_normal([2, 2])) # Wrong
print(a)
An error occurred when passing tf.random_normal to tf.constant:
TypeError: List of Tensors when single Tensor expected
2. The cause of the problem:
See how tf.constant() and tf.random_normal() are used
2.1 tf.random_normal function definition:
def random_normal(shape,
mean=0.0,
stddev=1.0,
dtype=dtypes.float32,
seed=None,
name=None):
- Returns: A tensor of the specified shape filled with random normal values.
2.2 tf.constant function definition:
def constant(value, dtype=None, shape=None, name="Const", verify_shape=False)
- value: A constant value (or list) of output type
dtype. - Returns: A Constant Tensor.
2.3 The cause of the problem:
Conclusion: Because the return value of tf.random_normal is a Tensor, but the parameter passed in by tf.constat is that the two types of the list do not match, an error occurs.
3. How to solve:
3.1 Method 1:
Use NumPy to generate the random value and put it in a tf.constant()
some_test = tf.constant(
np.random.normal(loc=0.0, scale=1.0, size=(2, 2)).astype(np.float32))
3.2 Method 2:
Potentially faster, as it can use the GPU to generate the random numbers,Use TensorFlow to generate the random value and put it in a tf.Variable
some_test = tf.Variable(
tf.random_normal([2, 2], mean=0.0, stddev=1.0, dtype=tf.float32)
sess.run(some_test.initializer)
View the definition of the tf.Variable function:
def __init__(self,
initial_value=None,
trainable=True,
collections=None,
validate_shape=True,
caching_device=None,
name=None,
variable_def=None,
dtype=None,
expected_shape=None,
import_scope=None,
constraint=None):
...
)
args: initial_value: A Tensor, or Python object convertible to a Tensor,which is the initial value for the Variable.
Next time you encounter this kind of function parameter problem, you must check how the function is used, and what the formal parameters and return values are.
Browser error: Lazy require of app.binding did not set the binding field
While debugging the code, the browser reported several errors as follows:
Lazy require of app.binding did not set the binding field
After searching for the information for a long time, I found an interesting phenomenon. I canceled all the breakpoints that were being debugged, and these errors disappeared, and then the breakpoints will not report this error.
java.lang.IllegalArgumentException: adding a window to a container
1. Error description
Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.checkNotAWindow(Container.java:490)
at java.awt.Container.addImpl(Container.java:1091)
at java.awt.Container.add(Container.java:1005)
at javax.swing.JFrame.addImpl(JFrame.java:567)
at java.awt.Container.add(Container.java:417)
at com.you.cmdp.frame.CheckBox.(CheckBox.java:42)
at com.you.cmdp.frame.CheckBox.main(CheckBox.java:62)
2. The reason for the error
public CheckBox()
{
frame.setBounds(100, 100, 400, 300);
frame.setFont(font);
frame.setForeground(Color.WHITE);
frame.setBackground(Color.BLACK);
add(frame);
cbOne.setText("Section 1");
cbTwo.setText("Section 2");
cbThree.setText("Section 3");
cbFour.setText("Section 4");
panel.add(cbOne);
panel.add(cbTwo);
panel.add(cbThree);
panel.add(cbFour);
frame.add(panel);
}
In the constructor, JFrame is inherited, but add(frame) will not be added again
3. Solution
public CheckBox()
{
frame.setBounds(100, 100, 400, 300);
frame.setFont(font);
frame.setForeground(Color.WHITE);
frame.setBackground(Color.BLACK);
//add(frame);
cbOne.setText("Section 1");
cbTwo.setText("Section 2");
cbThree.setText("Section 3");
cbFour.setText("Section 4");
panel.add(cbOne);
panel.add(cbTwo);
panel.add(cbThree);
panel.add(cbFour);
frame.add(panel);
}
How to Solve Error:‘itoa’ was not declared in this scope
Some compilers do not support itoa because it is not standard.
Solution
-
- c++11: std:: to_string
- sprintf
-
-
- stdio.h
char *c = new char;
sprintf(c,"%d",num);
-
-
- stringstream
-
-
- sstream.h
stringstream ss; int x = 1;
ss << x;
string str = ss.str();
-
Mac Upgrade pip Error OSError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/pip-9.0.1-py2….
Error Message:
Exception:
Traceback (most recent call last):
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py”, line 342, in run
prefix=options.prefix_path,
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py”, line 778, in install
requirement.uninstall(auto_confirm=True)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py”, line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py”, line 267, in renames
shutil.move(old, new)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 300, in move
rmtree(src)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/EGG-INFO/PKG-INFO’
You are using pip version 9.0.1, however version 19.1.1 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.
How to Solve this error:
When using pip to update a Python library under Mac, it prompts that the pip version is too low. The command line at the bottom shows that it needs to be upgraded. The upgrade command is: You should consider upgrading via the’pip install –upgrade pip’ command.
The command input given by the installation: pip install –upgrade pip; after the result is executed, the same error is still reported.
After retries N times, the execution still failed.
Finally, after searching online, I found out that it was a permission problem. Modify the execution command as follows:
sudo pip install –upgrade pip
How to Solve org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) Error
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) problem, that is, there is a problem when mapping and binding the dao interface and mapper configuration file in mybatis. Simply put, the interface and xml are either not found It is either
After the modification, the problem still exists. In the end, it took a lot of effort to find the source of my code problem. The file name of the dao interface is inconsistent with that of the xml.
Both the interface name and the interface file name are DepartmentDao, and the configuration file name is DeparmentDao.xml. It took a lot of effort to find a t letter in the names of both. After the modification, everything is normal.
This is a point that is easy to overlook. Remember: the interface name and the Mybatis mapping file name must be exactly the same.
incompatible types: ArrayList> cannot be converted to List>
- >
This error appeared when I tried to use an ArrayList<ArrayList<Integer>>() new a List<List<Integer>> object
List<List<Integer>> = new ArrayList<ArrayList<Integer>>();
Maybe we will find that if the second ArrayList is changed to List, the error is gone, so what is the principle?
After searching, it is found that this is a common pit of generic applications:
Generics, Inheritance, and Subtypes
https://docs.oracle.com/javase/tutorial/java/generics/inheritance.html
1. First, if A is a B, we can assign A to B
Object someObject = new Object();
Integer someInteger = new Integer(10);
someObject = someInteger; // OK
Integer inherits from Object and is a subtype of it, so there is no problem in assigning values in this way. This is a generic type.
2. Integer is also a kind of Number, and Double is also a kind of Number, so the following is also possible
public void someMethod(Number n) { /* … */ }
someMethod(new Integer(10)); // OK
someMethod(new Double(10.1)); // OK
You can also use generics:
Box<Number> box = new Box<Number>();
box.add(new Integer(10)); // OK
box.add(new Double(10.1)); // OK
3. Here comes the point
public void boxTest(Box<Number> n) { /* … */ }
If so, can we pass in Box<Integer> or Box<Double>
the answer is negative.
Integer is a subclass of Number, and Double is also a subclass of Number. However, Box<Integer> and Box<Double> are not subclasses of Box<Integer>. Their relationship is parallel, and both are subclasses of Object.
How to Solve ImportError: cannot import name gof
Open spyder today and say to debug a theano program, but import theano prompt
ImportError: cannot import name gof
Final solution
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Hash_map is deprecated and will be REMOVED. Please use unordered_map.
Hash_map is a C++ non-standard STL. Because of the advancement of standardization, hash_map is a non-standard container, and it will be replaced by unordered_map in the future. Suggest that we use unorder_map instead of hash_map, the solution
(1) Replace <hash_map> with <unorder_map> or
(2) Add macro definition to ignore this error
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS //Adding this macro definition means that no error is reported
#ifndef _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
static_assert(false, " is deprecated and will be REMOVED. "
"Please use . You can define "
"_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS "
"to acknowledge that you have received this warning.");
#endif /* _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS */