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

pypr throws error #7

Closed
KSaiAkshit opened this issue Jun 30, 2023 · 12 comments
Closed

pypr throws error #7

KSaiAkshit opened this issue Jun 30, 2023 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@KSaiAkshit
Copy link

I wanted to setup some scratchpads, and i followed the guide on their github page. I had to install it from the AUR, because pip kept complaining about externally managed packages. I also tried using pipx for that matter, but it doesn't seem to work.

Traceback (most recent call last):
  File "/usr/bin/pypr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 171, in main
    asyncio.run(run_daemon() if len(sys.argv) <= 1 else run_client())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 162, in run_client
    _, writer = await asyncio.open_unix_connection(CONTROL)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 98, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 259, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    sock.connect(address)

I get this error when I manually try to run pypr toggle term. This is also the case with hpr-scratcher. I can see that processes are spawned, but i just can't seem to access the scratchpads.
I also don't see pypr in btop after restarting. I do have the exec-once line in hyprland.conf

@ModestasStankus
Copy link

I have same issue.

@fdev31
Copy link
Collaborator

fdev31 commented Jul 10, 2023

I think you partially broke your OS packaging system because you performed some (global ?) package installations without relying on it.
You SHOULD install it from AUR, not using pip (ideally).
Can you remove all your pip-installed packages and try again ?

@KSaiAkshit
Copy link
Author

Just for clarification, what do you mean remove all pip-installed packages? I have quite a few packages, here is the out put for pip list: https://pastebin.com/QZc5J4cs
I did try installing it from AUR, in fact, that's how I did it at first. It didn't work either.

@fdev31
Copy link
Collaborator

fdev31 commented Jul 11, 2023

This is not really pypr related I think, it's more a python package management usage problem.
To be confirmed, but pip list will show every accessible package, not only the manually installed ones.

If you are not an experienced developer or having really good knowledge about python packaging system, I would stay away from pip or any kind of manual python package installation - unless it's in a virtual environment (venv).
You may want to try the following to fix your python installation:

  • remove everything installed by pip or manually (includes ~/.local , /usr/local , etc...)
  • re-install every python package you need, including the already installed ones, you may need to use --overwrite to achieve that - there is a chance some of your files were replaced by manually installed packages.

Be aware, you may have more than one python version, check the default one first (just type python --version).

Once you are done cleaning up your python installation, check if the problem persists.
I would suggest running pypr in debug mode manually instead of running it from the hyprland config file when you "debug" the behavior, you can get more traces by typing:

DEBUG=1 pypr to to start pypr

Here I should probably add a better/specific error handling:
"Can not connect to pypr daemon" or something like this.

Keep me informed if you make some progress, I'll keep this bug open to improve the error handling in the meantime.

Before doing anything, my instructions might not be sufficient, I suggest you read a lot about such situation (it's a classical "mistake", people not using virtual environments and copying instructions using pip...). One radical option to skip reading docs is uninstall everything python related (OS packages first) after making a list, then install them again from the list, in between the two steps you had manually removed every trace of python which is "not official" to your OS...

Hope it helps!

@fdev31
Copy link
Collaborator

fdev31 commented Jul 11, 2023

By the way, I digressed with the pip problem.
Here pypr didn't start, you can remove everything from the hyprland config, and run manually in a terminal:

DEBUG=1 pypr

You'll have traces and pypr will run in the foreground in this window. I bet it's not starting, you'll see why (you can paste the content here).

@Gerzulet
Copy link

I have the same problem, if i run pypr on a terminal, and use the keyboard shortcuts (i.e. term scratchpad), it works fine, of course this means i must have the terminal open with pypr running, which defeats the purpose.
Still havent tried reinstalling the python packages, although i installed this with yay.

@fdev31
Copy link
Collaborator

fdev31 commented Jul 26, 2023

you can make a script which will log the error, I hope it will provide more useful information:

#!/bin/bash
DEBUG=1 pypr > /tmp/pypr.log

Use this script instead of "pypr" in the exec-once and then check the log file...

@fdev31
Copy link
Collaborator

fdev31 commented Jul 28, 2023

I changed something in the master branch, fixing a race condition - it's also a possibility for this bug.
You might be interested in upgrading to the git version to test it in case you suffer from this problem.

@fdev31 fdev31 self-assigned this Jul 29, 2023
@fdev31 fdev31 added the enhancement New feature or request label Jul 29, 2023
@fdev31
Copy link
Collaborator

fdev31 commented Jul 29, 2023

I added better error handling in master.
You can also log to a file using --debug path_to_some_file.txt.
On startup, run pypr with this flag so we can fetch the output easily.
When failing, I hope you'll get more comprehensible error message.

@fdev31
Copy link
Collaborator

fdev31 commented Aug 1, 2023

Released version 1.4.0, hoping you'll get better debug output helping you understand this problem.
Error handling can still be improved, please share your feedback.
I'll close this bug until more details are provided, discarding an environment anomaly.

@fdev31 fdev31 closed this as completed Aug 1, 2023
@MysticBytes786
Copy link

I wanted to setup some scratchpads, and i followed the guide on their github page. I had to install it from the AUR, because pip kept complaining about externally managed packages. I also tried using pipx for that matter, but it doesn't seem to work.

Traceback (most recent call last):
  File "/usr/bin/pypr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 171, in main
    asyncio.run(run_daemon() if len(sys.argv) <= 1 else run_client())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 162, in run_client
    _, writer = await asyncio.open_unix_connection(CONTROL)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 98, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 259, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    sock.connect(address)

I get this error when I manually try to run pypr toggle term. This is also the case with hpr-scratcher. I can see that processes are spawned, but i just can't seem to access the scratchpads. I also don't see pypr in btop after restarting. I do have the exec-once line in hyprland.conf

Use pip check to identify any missing or broken dependencies. I had to downgrade some packages.

@lightmon233
Copy link

I wanted to setup some scratchpads, and i followed the guide on their github page. I had to install it from the AUR, because pip kept complaining about externally managed packages. I also tried using pipx for that matter, but it doesn't seem to work.

Traceback (most recent call last):
  File "/usr/bin/pypr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 171, in main
    asyncio.run(run_daemon() if len(sys.argv) <= 1 else run_client())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyprland/command.py", line 162, in run_client
    _, writer = await asyncio.open_unix_connection(CONTROL)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 98, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/unix_events.py", line 259, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    sock.connect(address)

I get this error when I manually try to run pypr toggle term. This is also the case with hpr-scratcher. I can see that processes are spawned, but i just can't seem to access the scratchpads. I also don't see pypr in btop after restarting. I do have the exec-once line in hyprland.conf

same issue. solved.
you should run pypr as server first, then when you run pypr you may get some error, for me it's "placement ...", then you should add "monitors" option in your pyprland.json file
like this

"monitors": {
    "placement": {
      "BenQ PJ": {
        "topOf": "VGA-1"
      }
    },
    "unknown": "wlrlui"
}

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

No branches or pull requests

6 participants