今天在使用python的扩展包的时候遇到了一些问题特此记录下来。
首先看一下有什么命令:
Standard commands:
build build everything needed to install
build_py "build" pure Python modules (copy to build directory)
build_ext build C/C++ extensions (compile/link to build directory)
build_clib build C/C++ libraries used by Python extensions
build_scripts "build" scripts (copy and fixup #! line)
clean clean up temporary files from 'build' command
install install everything from build directory
install_lib install all Python modules (extensions and pure Python)
install_headers install C/C++ header files
install_scripts install scripts (Python or otherwise)
install_data install data files
sdist create a source distribution (tarball, zip file, etc.)
register register the distribution with the Python package index
bdist create a built (binary) distribution
bdist_dumb create a "dumb" built distribution
bdist_rpm create an RPM distribution
bdist_wininst create an executable installer for MS Windows
upload upload binary package to PyPI
check perform some checks on the package
Extra commands:
rotate delete older distributions, keeping N newest files
develop install package in 'development mode'
setopt set an option in setup.cfg or another config file
saveopts save supplied options to setup.cfg or other config file
egg_info create a distribution's .egg-info directory
install_egg_info Install an .egg-info directory for the package
alias define a shortcut to invoke one or more commands
easy_install Find/get/install Python packages
bdist_egg create an "egg" distribution
test run unit tests after in-place build
File “/mnt/data-1/data/bingqian.geng/aiot_predictor/utils/mesh_cython/init.py”, line 8, in
from utils.mesh_cython import mesh_core_cython
ImportError: cannot import name ‘mesh_core_cython’ from ‘utils.mesh_cython’
我运行的时候,里面有.so文件,说明是已经便宜过的代码了,但是运行python setup.py install
不会报错的,就是一运行就报上面的错误,这里的.so文件是在其他环境中编译的,在这个环境里面因为里面的包版本不一样的,所以说就会报错,使用下面的代码重新编译
python setup.py build_ext --inplace
然后再执行 python setup.py install
就可以了