[tips]PythonMagick的安装

本文详细介绍PythonMagick的安装步骤及其过程中可能遇到的问题及解决方案,包括配置环境变量、修改源代码等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        PythonMagick是ImageMagick的python开发包。
        下载: PythonMagick-0.7.tar.gz
        安装之前确认是否安装了下列库或包:
        boost
        boost-python
        python 2.5
        Magick++ (>= 6.2)
        还要确认是否安装了下列工具:
        pkg-config
        libtool
        make
        然后执行下列命令进行安装:
        $ tar -xzf PythonMagick-0.7.tar.gz
        $ cd PythonMagick-0.7
        $ ./configure
        $ make
        $ make install
        make install的时候,必须具备root权限,看起来似乎很顺利,标准的安装过程,但是实际上一开始就出问题了
        问题一: ./configure的时候找不到ImageMagick,实际上我是安装了的,关于ImageMagick的安装请参看我的博文: [tips]ImageMagick软件包简介及安装,这个时候进入当前登录用户的home目录,打开.bash_profile文件,加入以下几行:
        PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
        export PKG_CONFIG_PATH
        其中/usr/local/lib/pkgconfig为ImageMagick的包描述文件所在目录
        保存并退出到命令行后,执行下列命令使之生效:
        $ source .bash_profile
        做完上述配置后,./configure是没有问题了。
        问题二: make的时候会报 no matching function for call to 'registry_lookup(const volatile void (*)())' 的错误,这个问题比较麻烦,在google上找了很久,说是boost-python不再支持void*的原因,经过自己的一些尝试,才找到解决办法:
        1 首先把下列提及文件中的void* or void * 全部替换为unsigned char* or unsigned char *,注意在替换的时候,要符合c++的语法:
        PythonMagick-0.7/pythonmagick_src/_Blob.cpp _Image.cpp
        /usr/local/include/Magick++/Blob.h Image.h
        其中/usr/local/include/Magick++为ImageMagick安装后的头文件,可能会有所不同;
        2 进入PythonMagick-0.7/pyste_src,找到Blob.pyste、Image.pyste,更改文件中的路径为正群的安装路径;
        3 进入PythonMagick-0.7/helpers_src,找到Blob.cpp,打开,将其内容替换为:
cpp 代码
  1. #include "Blob.h"
  2. void update_wrapper(Magick::Blob& blob, const std::string& data) {
  3. blob.update((unsigned char*)(const_cast<char*>(data.c_str())),data.size());
  4. }
  5. std::string get_blob_data(const Magick::Blob& blob) {
  6. const unsigned char* data = static_cast<const unsigned char*>(blob.data());
  7. size_t length = blob.length();
  8. return std::string(data,data+length);
  9. }
        做完以上设置后,按照安装步骤走,就搞定了,如果编译过程中出现问题,就再仔细检查1中所提到的文件中的void *指针是否替换完,因为有几个地方,void和*之间会有很多空格,要注意检查。
Sure, here are some tips for installing EGSnrc on Ubuntu: 1. Update your system: Before starting the installation process, it's always a good idea to update your system. Open a terminal and run the following command: ``` sudo apt update && sudo apt upgrade -y ``` 2. Install required dependencies: EGSnrc requires some libraries and packages to be installed. Run the following command to install them: ``` sudo apt install build-essential gfortran libx11-dev libxt-dev libxpm-dev libxft-dev libxmu-dev libglu1-mesa-dev ``` 3. Download the EGSnrc distribution: Visit the EGSnrc website (https://nrc-cnrc.github.io/EGSnrc/) and download the latest distribution file (e.g., egsnrc_vn.mmm.tar.gz), where "vn" represents the version number and "mmm" represents the release number. 4. Extract the distribution: Open a terminal and navigate to the directory where you downloaded the distribution file. Use the following command to extract it: ``` tar -xvf egsnrc_vn.mmm.tar.gz ``` 5. Set up environment variables: In order to use EGSnrc, you need to set up some environment variables. Open your shell configuration file (e.g., ~/.bashrc) in a text editor and add the following lines at the end: ``` export EGS_HOME=/path/to/egsnrc export EGS_CONFIG=/path/to/egsnrc/HEN_HOUSE/specs/your_machine_name export PATH=$PATH:$EGS_HOME/bin/$my_machine ``` Replace "/path/to/egsnrc" with the actual path where you extracted the EGSnrc distribution, and "your_machine_name" with the appropriate name for your machine (e.g., linux). 6. Compile EGSnrc: Open a terminal and navigate to the EGSnrc directory. Run the following command to compile EGSnrc: ``` make ``` 7. Verify the installation: After the compilation process completes successfully, you can run some example simulations provided with EGSnrc to verify the installation. Refer to the EGSnrc documentation for instructions on running the examples. That's it! You have now successfully installed EGSnrc on Ubuntu. Remember to consult the EGSnrc documentation for further usage instructions and details.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值