Changing LD_LIBRARY_PATH at runtime for ctypes

后端 未结 5 1948
南笙
南笙 2020-11-27 15:14

How do you update this environment variable at runtime so that ctypes can load a library wherever? I\'ve tried the following and neither seem to work.

from c         


        
5条回答
  •  無奈伤痛
    2020-11-27 15:44

    Setting LD_LIBRARY_PATH to the path where libraries are placed won't work here and ctypes will not notice any changes. So, you need to et this at the source and run ldconfig before your script to take this into account. Moreover setting the os environment or any PATH variable in the script will have no effect.

    I was facing similar issue and having spent around a day to figure this out.

    #mkdir -p /etc/ld.so.conf.d/
    #echo "/home/starlon/Projects/pyCFA635/lib" > /etc/ld.so.conf.d/mycustomPath.conf
    
    #ldconfig
    

    Then verify if the path is set by

    # ldconfig -v | less
    

    After this is done, try to run your script. This has worked for me and should work for also.

    You can see below URL which helped me to resolve this:

    https://www.cyberciti.biz/faq/linux-setting-changing-library-path/

    Note: I realized the question is old, however wanted to contribute to this as the accepted answer alone was not actually solving the problem.

提交回复
热议问题