Python二进制文件在直接调用时不考虑.bashrc中的路径

时间:2015-08-05 04:19:50

标签: bash wxpython pyinstaller

我在从wxpython(使用pyinstaller)构建的linux上运行了GUI应用程序的二进制文件(带有一组.so文件)。应用程序使用subprocess.Popen()在内部调用许多子应用程序,这需要设置一些环境PATH变量。

我已经在〜/ .bashrc中添加了路径..从bash shell调用时,应用程序运行正常。

private CameraCaptureSession.CaptureCallback mCaptureCallback
        = new CameraCaptureSession.CaptureCallback()    {
    private void process(CaptureResult result)  {
        switch(mState)  {
            case STATE_PREVIEW: break;
            case STATE_WAITING_LOCK:
                // checking if result.get(CaptureResult.FLASH_STATE) == 
                // CaptureResult.FLASH_READY over here didn't work because
                // null was returned
                int afState = result.get(CaptureResult.CONTROL_AF_STATE);
                if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
                        CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) {
                    Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
                    if (aeState == null ||
                            aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
                        mState = STATE_WAITING_NON_PRECAPTURE;
                        captureStillPicture();
                    } else {
                        runPrecaptureSequence();
                    }
                }
                break;
            case STATE_WAITING_PRECAPTURE:
                Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
                if (aeState == null ||
                        aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
                        aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED) {
                    mState = STATE_WAITING_NON_PRECAPTURE;
                }
                break;
            case STATE_WAITING_NON_PRECAPTURE:
                Integer aeState1 = result.get(CaptureResult.CONTROL_AE_STATE);
                if (aeState1 == null || aeState1 != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
                    mState = STATE_PICTURE_TAKEN;
                    captureStillPicture();
                }
                break;
        }
    }

    @Override
    public void onCaptureProgressed(CameraCaptureSession session,
                                    CaptureRequest request, CaptureResult partialResult) {
        super.onCaptureProgressed(session, request, partialResult);
        process(partialResult);
    }

    @Override
    public void onCaptureCompleted(CameraCaptureSession session,
                                   CaptureRequest request, TotalCaptureResult result) {
        super.onCaptureCompleted(session, request, result);
        process(result);
    }
};

但是,如果我直接打开二进制文件(双击),则由于缺少路径,子应用程序调用将失败。因为它在从bash调用时工作正常,所以我尝试使用以下命令创建applicationwrapper.sh,但没有帮助。

./applicationname

知道如何分发应用程序,以便用户可以直接打开它而不是通过bash shell来调用它吗?

1 个答案:

答案 0 :(得分:0)

如果发现环境变量不存在,您是否考虑过从配置文件中读取变量?