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

No module found named colors #31

Closed
sohang3112 opened this issue Apr 21, 2022 · 6 comments
Closed

No module found named colors #31

sohang3112 opened this issue Apr 21, 2022 · 6 comments

Comments

@sohang3112
Copy link

sohang3112 commented Apr 21, 2022

Running ptghci gives the following error:

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "<INSTALL_PATH>/ptghci/.stack-work/install/x86_64-linux-tinfo6/7357d9c15e35ae82d15105d3acb5462b048972d21d113830a6c533cd8c158187/8.8.3/share/x86_64-linux-ghc-8.8.3/ptghci-0.1.0.0/pybits/ptghci/app.py", line 5, in <module>
    import colors
ModuleNotFoundError: No module named 'colors'

Note:

  • The above error occured in Ubuntu 20.04 on both desktop as well as on WSL 2.
  • Python 3.10 was used.

Proposed Fix: Wherever colors is imported in Python code, it should instead be replaced by colour module - see its PyPi link

@RichardWarfield
Copy link
Collaborator

The package name is actually ansicolors. Did you do pip3 install -r pybits/requirements.txt?

@sohang3112
Copy link
Author

Yes, I definitely did pip3 install -r pybits/requirements.txt (just to be sure, I did it again just now). I also tried doing pip3 install ansicolors just now. But the same error still appears.

@RichardWarfield
Copy link
Collaborator

That's strange. What happens if you start a python repl and do import colors? Can python find the library?

The installation process for ptghci is really suboptimal. I've been meaning to package something up with nix for a while, which would be much nicer at least if you don't mind using nix.

@sohang3112
Copy link
Author

sohang3112 commented Apr 22, 2022

Yes, import colors works in a Python REPL - but for some reason it doesn't work in the ptghci code.

Edit: Oh, I got the issue now - I had activated a conda environment, so pip installed the requirements in the same environment. But ptghci was running using the system python /usr/bin/python3 - that's why it couldn't find the dependencies!

@RichardWarfield
Copy link
Collaborator

Yup my next question was going to be whether you had some kind of virtualenv going on :-)

This really should be considered a flaw in ptghci - we shouldn't require installation next to your system python libraries. I'd like to get rid of the python dependency altogether (which would basically require re-implementing much of prompt-toolkit); the next best thing would be something like nix that can manage the python environment without messing with the system python install.

@sohang3112
Copy link
Author

One fix for this would be for ptghci to use the python in the user's environment, and fall back to the system python if not found. So instead of /usr/bin/python3, pthghci should use /usr/bin/env python3.

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