Q&A

1
AttributeError: module 'numpy' has no attribute 'typeDict'

According to the trace, I find this error is generated by import scipy.optimize. I check the version of scipy anf it’s 1.3.3, which is default version on Ubuntu20.04 and it’s outdated. It can be solved by installing new version.

# update to newest version
pip3 install --upgrade scipy
# update to specific version
pip3 install scipy==1.10.1
2
BOOST_PYTHON_MODULE(libnumpy_eigen) {
  using namespace boost::python;
  import_array();
}

I got an error during compilation.

error: void function 'init_module_libnumpy_eigen' should not return a value [-Wreturn-type]
  import_array();

Change code like below

BOOST_PYTHON_MODULE(libnumpy_eigen) {
  using namespace boost::python;
  _import_array();
}

or

BOOST_PYTHON_MODULE(libnumpy_eigen) {
  using namespace boost::python;
  if(_import_array() < 0) 
  {
    return nullptr;
  }
}
3
ConnectionResetError: [Errno 104] Connection reset by peer
4
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'
5
Indentation: unident does not match any outer indentation level

check indentation.

6
AttributeError: partially initialized module 'csv' has no attribute 'writer' (most likely due to a circular import)

This error almost always happens when your script is named csv.py, or when there’s another file named csv.py (or csv.pyc) in the same directory as your script.

Python has a built-in module called csv, and when you run your script, Python imports your file instead of the standard library one — causing the circular import error.