bash 在 Ubuntu 中重新创建 PyCharm 启动器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19738980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Recreating PyCharm launcher in Ubuntu
提问by Games Brainiac
I installed pycharm normally via bin/pycharm.sh
, but the mistake I made was doing bash pycharm.sh
whilethe pycharm directory has inside the Downloads folder.
我安装pycharm正常通过bin/pycharm.sh
,但我犯的错在做bash pycharm.sh
,而在pycharm目录有下载文件夹内。
I later on moved the directory to /opt/Pycharm/
. This is causing the once functioning unity launcher (which was added when PyCharm was initially installed) to fail every time I attempt to use it (as expected).
后来我将目录移动到/opt/Pycharm/
. 这导致曾经运行的统一启动器(在最初安装 PyCharm 时添加)在我每次尝试使用它时失败(如预期的那样)。
How can I re-add pycharm.sh
as a lauchable app from the unity launcher? I know the location of the pycharm.sh
file. I've tried to add it to /usr/bin/
but that does not change anything.
如何pycharm.sh
从统一启动器重新添加为可发布的应用程序?我知道pycharm.sh
文件的位置。我试图将它添加到,/usr/bin/
但这并没有改变任何东西。
I can still launch pycharm via bash /usr/opt/Pycharm/bin/Pycharm.sh
. But this is tedious.
我仍然可以通过bash /usr/opt/Pycharm/bin/Pycharm.sh
. 但这很乏味。
UPDATE
更新
I have tried making a new .desktop
file for pycharm, using the following script:
我尝试.desktop
使用以下脚本为 pycharm创建一个新文件:
[Desktop Entry]
Encoding=UTF-8
Name=PyCharm
Exec=/opt/Pycharm-3.0.1/bin/pycharm.sh
Icon=/opt/Pycharm-3.0.1/bin/PyCharm_32.png
Type=Application
Categories=Development;
StartupWMClass=PyCharm
However, I get a "Unable to save Pycharm.desktop" error when I try to save the file inside /usr/share/applications/pycharm.desktop
. Any help regarding this would be deeply appreciated.
但是,当我尝试将文件保存在/usr/share/applications/pycharm.desktop
. 对此的任何帮助将不胜感激。
回答by Shan Valleru
First start pyCharm
from it's bin folder via command line
首先pyCharm
通过命令行从它的 bin 文件夹开始
$ ./pycharm.sh
$ ./pycharm.sh
Then, goto
然后,转到
Tools -> Create Desktop Entry
.
Tools -> Create Desktop Entry
.
It will create a correct Desktop file in the correct place. Afterward you can initiate it from the menu and pin the icon or drag and drop it to the bar. This way, you don't have to deal with .desktop
files and mumbo jumbo..
它将在正确的位置创建正确的桌面文件。之后,您可以从菜单启动它并固定图标或将其拖放到栏中。这样,您就不必处理.desktop
文件和笨拙的巨无霸..
回答by Games Brainiac
I managed to solve it. The thing is, Pycharm already installs a launcher inside .local/share/applications
. Thus, you need to get rid of it before proceeding to create your own. After that, all you have to do is add your own *.desktop
file to the applications
directory inside usr/share/applications/
.
我设法解决了它。问题是,Pycharm 已经在里面安装了一个启动器.local/share/applications
。因此,在继续创建自己的之前,您需要摆脱它。在此之后,所有你需要做的就是添加你自己的*.desktop
文件到applications
目录中usr/share/applications/
。
You need to create your .desktop
file using sudo
and inside the desktop file:
您需要.desktop
使用sudo
桌面文件并在其中创建文件:
[Desktop Entry]
Encoding=UTF-8
Name=PyCharm
Exec=/opt/pycharm-3.0.1/bin/pycharm.sh
Icon=/opt/pycharm-3.0.1/bin/pyCharm.png # Changed from pycharm_32.png
Type=Application
Categories=Development;
StartupWMClass=PyCharm
After that is done, you can launch your app properly. Please note that pycharm.sh
must also have execution rights.
完成后,您可以正确启动您的应用程序。请注意,pycharm.sh
还必须具有执行权。
回答by davidA
With Ubuntu 16.04, I used the "snap" installer, which doesn't include an easily accessible icon (there's probably one hidden inside the snap image, but it's hard to get at). Instead it shows a grey question mark icon in the launcher instead. Also there doesn't seem to be a Tools > Create Desktop Entryoption in version 2017.3.3 as far as I can see - maybe it has been moved somewhere.
在 Ubuntu 16.04 中,我使用了“snap”安装程序,它不包含易于访问的图标(快照图像中可能隐藏了一个图标,但很难找到)。相反,它在启动器中显示一个灰色的问号图标。此外,据我所知,2017.3.3 版本中似乎没有“工具”>“创建桌面条目”选项 - 也许它已被移到某处。
So I copied pycharm.png
from an earlier non-snap Community installation, saved it somewhere, then created ~/.local/share/applications/jetbrains-pycharm-ce.desktop
:
所以我pycharm.png
从早期的非快照社区安装中复制,将其保存在某处,然后创建~/.local/share/applications/jetbrains-pycharm-ce.desktop
:
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/path/to/pycharm.png
Exec="/snap/bin/pycharm-community" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
Then when I start PyCharm (from the command line), the launcher item appears with the correct icon, and then I right-click on it and choose "Lock to Launcher", and it now persists.
然后,当我启动 PyCharm(从命令行)时,启动器项目会显示正确的图标,然后我右键单击它并选择“锁定到启动器”,它现在仍然存在。
A downside is that the icon will not be automatically updated with the app, so it might fall out of date.
一个缺点是图标不会随应用程序自动更新,因此它可能会过时。
回答by pzrq
In case you just want to update your launcher to point to an updated PyCharm, for me changing 4.0.4 to 4.0.6 in the following worked:
如果您只想更新您的启动器以指向更新的 PyCharm,那么我将 4.0.4 更改为 4.0.6,如下所示:
nano /usr/share/applications/jetbrains-pycharm.desktop
回答by Gal Margalit
When Tools -> Create Desktop Entry does not work:
Create a new file on your desktop (using vi or a similar command) named:
jetbrains-pycharm.desktop
Paste the following inside:
当 Tools -> Create Desktop Entry 不起作用时:
在桌面上创建一个名为:
jetbrains-pycharm.desktop的新文件(使用 vi 或类似命令),
将以下内容粘贴到其中:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm
Icon=/opt/pycharm-5.0.1/bin/pycharm.png
Exec="/opt/pycharm-5.0.1/bin/pycharm.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm
Keep in mind to change the path and version number of iconand execproperties above.
Tested on various versions of PyCharm - like a charm ?
请记住更改上面的icon和exec属性的路径和版本号。
在各种版本的 PyCharm 上进行测试 - 就像一个魅力?
回答by Miroslav Bratanov
Simply replaced the Icon=/path/to/pycharm.png
in ~/.local/share/applications/jetbrains-pycharm-ce.desktop
from meowsqueak's answer with the correct path when installed from snap.
简单地取代了Icon=/path/to/pycharm.png
在~/.local/share/applications/jetbrains-pycharm-ce.desktop
从卡扣安装时从meowsqueak的使用正确的路径答案。
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/snap/pycharm-community/current/bin/pycharm.png
Exec="/snap/bin/pycharm-community" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
回答by Fermi paradox
Ubuntu 16.04(haven't checked prior versions)
Ubuntu 16.04(尚未检查以前的版本)
Run pycharm.sh
(make sure you use the correct dir and PyCharm version below):
运行pycharm.sh
(确保您使用正确的目录和下面的 PyCharm 版本):
$ ./dir_where_you_placed_it/pycharm-2016.1.4/bin/pycharm.sh
While PyCharm is running, right click its icon on the Launcher and select "lock to Launcher"
.
在 PyCharm 运行时,右键单击启动器上的图标并选择"lock to Launcher"
。
回答by Rasmi Ranjan Nayak
Run $ pycharm-community
Right after you will see the icon on the taskbar
.
Right Click, select Lock on the Taskbar
.
Somewhat solves the problem.
运行$ pycharm-community
后,您将看到 图标上的图标taskbar
。右键单击,选择Lock on the Taskbar
。一定程度上解决了问题。
回答by DevMin
I guess you didn't check 'Create the entry for all users (requires superuser privileges)'option on Tools -> Create Desktop Entry. You should check it.
我猜您没有选中“工具”->“创建桌面条目”上的“为所有用户创建条目(需要超级用户权限)”选项。你应该检查一下。
You don't have to create something new.
你不必创造新的东西。
回答by Tshilidzi Mudau
Simply type this on your terminal window:
只需在终端窗口中输入:
jetbrains-pycharm.desktop
Hope that helps :)
希望有帮助:)