Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xclip installed but: Pyperclip could not find a copy/paste mechanism for your system #259

Open
nick-youngblut opened this issue Mar 29, 2024 · 3 comments

Comments

@nick-youngblut
Copy link

nick-youngblut commented Mar 29, 2024

I'm using Debian GNU/Linux 12 (FROM python:3.9-slim-buster), and have xclip installed.

However, in my streamlit app, I'm still getting the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 659, in lazy_load_stub_copy
    return copy(text)
  File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 336, in __call__
    raise PyperclipException(EXCEPT_MSG)
pyperclip.PyperclipException: 
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error 

I'm using pyperclip==1.8.2

My dockerfile:

# Use an official Python runtime as a base image
FROM python:3.9-slim-buster

# Set the working directory in the container
WORKDIR /app

# Install system dependencies
RUN apt-get update \
    && apt-get install -y git xclip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements.txt file into the container
COPY requirements.txt .

# Install Python dependencies
RUN pip3 install -r requirements.txt

# Copy the app files into the container
COPY bridge_rna_designer/ ./bridge_rna_designer/
COPY .streamlit/ ./.streamlit/
COPY img/ ./img/
COPY app.py ./

# Make port ${PORT} available to the world outside this container
EXPOSE ${PORT}

# Run the app when the container launches
CMD sh -c "streamlit run app.py \
  --server.headless true \
  --server.fileWatcherType none \
  --browser.gatherUsageStats false \
  --server.port=${PORT} \
  --server.address=0.0.0.0"

My requirements.txt file:

biopython==1.83
click==7.0
python-dotenv==1.0.0
streamlit==1.31.1
pyperclip==1.8.2

The relevant streamlit code is basically the same at shown in https://discuss.streamlit.io/t/how-to-add-copy-to-clipboard-button-to-text-area/49648/2.

@nick-youngblut
Copy link
Author

@asweigart the docs state:

pip install gtk to install the gtk Python module.

...but does the gtk package still exist on pypi? I can't find it.

The same goes for PyQt4. I only see PyQt5 and PyQt6.

@nick-youngblut
Copy link
Author

@asweigart should this repo be considered a public archive, since it has not been updated in 3 years?

@Nagasaki45
Copy link

Nagasaki45 commented Jun 16, 2024

I had a similar issue the other day when using pyperclip in GitHub Actions. The issue was solved by using Xvfb. If my understanding is correct, while xclip and the other copy/paste mechanisms provide the ability to copy and paste from the clipboard, the clipboard itself is provided by X, which Xvfb emulates. In my case the solution was something like this:

sudo apt-get -y install xvfb
xvfb-run pytest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants