我有一个应用程序(它是 cura,本地构建的),我使用以下命令从命令行启动它:
cd 我的/cura/文件夹
源 venv/bin/activate
PYTHONPATH=../lib/python3/dist-packages./cura
我怎样才能做同样形式的桌面文件?
这是我制作的 .desktop 文件:
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Cura
GenericName=Slicer application
Comment=Prepare model for 3d printing
MimeType=model/stl;application/prs.wavefront-obj;application/vnd.ms-3mfdocument;text/x-gcode
Icon=cura-icon
Type=Application
Categories=3DGraphics;GUIDesigner;Graphics
Keywords=Slicer
Path=/home/kurvivor/Development/cura
Exec=source venv/bin/activate;cd cura-build/build/inst/bin; PYTHONPATH=../lib/python3/dist-packages ./cura
Terminal=true
但是,我尝试启动时得到的提示是“启动应用程序时出错。当我转到我设置的路径并执行我在 exec 中输入的相同命令时,应用程序可以正常启动。
答案1
PYTHONPATH 环境变量需要包含完整路径
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Cura
GenericName=Slicer application
Comment=Prepare model for 3d printing
MimeType=model/stl;application/prs.wavefront-obj;application/vnd.ms-3mfdocument;text/x-gcode
Icon=cura-icon
Type=Application
Categories=3DGraphics;GUIDesigner;Graphics
Keywords=Slicer
Path=/home/kurvivor/Development/cura
Exec=source venv/bin/activate;cd cura-build/build/inst/bin; env PYTHONPATH=complete/path/lib/python3/dist-packages ~/cura
Terminal=true