I am trying to copy something to my clipboard for a project in Python. I cannot use modules to copy to my clipboard because of a bug with KDE Plasma. Instead of trying to fix that problem, I decided I would work around it with:
os.system('echo text | xclip -sel clip')
The error I get in return, is
sh: xclip: command not found
Xclip is installed and works in my own commandline just fine, but with the terminal within Pycharm. The command sudo
is not recognized. I do not understand why these are not being recognized, and what I must do to be able to access something like xclip from the built-in terminal.
Within my functional drop-down:
$PATH
bash: /home/danielh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin: No such file or directory
Within my dysfunctional built-in terminal:
echo $PATH
/home/danielh/PycharmProjects/DetermineDistances/venv/bin:/app/bin:/usr/bin
sudo pacman is not recognized either, why am I missing these commands?
[danielh@Pomegranate DetermineDistances]$ which pacman
which: no pacman in (/app/bin:/usr/bin)
[danielh@Pomegranate DetermineDistances]$ which xclip
which: no xclip in (/app/bin:/usr/bin)
I have put clipboard.sh
in the project directory, but even when it is run, xclip is not found. However, if I run it from my own terminal, it works just fine:
subprocess.call('./clipboard.sh') ./clipboard.sh: line 2: xclip: command not found
[danielh@Pomegranate DetermineDistances]$ ./clipboard.sh
works just fine
[danielh@Pomegranate DetermineDistances]$ which xclip /usr/bin/xclip
also works
@CrazyCoder's solution doesn't seem to have any effect.
[danielh@Pomegranate bin]$ sudo /var/lib/flatpak/app/com.jetbrains.PyCharm-Community/current/active/export/bin/com.jetbrains.PyCharm-Community
PyCharm opens up, yet I am still unable to access pacman
or xclip
(venv) [danielh@Pomegranate DetermineDistances]$ strace -e stat which xclip
strace: test_ptrace_get_syscall_info: PTRACE_TRACEME: Operation not permitted
strace: ptrace(PTRACE_TRACEME, ...): Operation not permitted
strace: PTRACE_SETOPTIONS: Operation not permitted
strace: detach: waitpid(157): No child processes
strace: Process 157 detached
I have resolved the issue by uninstalling the Flatpak repository installation of PyCharmCE and reinstalling PycharmCE 2020.1.3 using the Snap repository.
[danielh@Pomegranate PycharmProjects]$ whereis xclip
xclip: /usr/bin/xclip /usr/share/man/man1/xclip.1.gz
[danielh@Pomegranate PycharmProjects]$ whereis sudo
sudo: /usr/bin/sudo /usr/lib/sudo /etc/sudo.conf /usr/share/man/man8/sudo.8.gz