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 folders to install into are found when run in a virtual environment #53

Open
williamstark01 opened this issue Sep 19, 2022 · 1 comment

Comments

@williamstark01
Copy link

This issue is the same as #39, unclear why it resurfaced.

When pretty_errors is run as a module inside a pyenv virtualenv to add it to Python startup procedure (python -m pretty_errors), no folders to install into are found.

Updating the regexes should resolve this.

As a workaround I hardcoded the path to site-packages:

vim $(pyenv prefix)/lib/python3.9/site-packages/pretty_errors/__main__.py

# set paths in line 50 to
            # paths = ['<$(pyenv prefix)>/lib/python3.9/site-packages']
@rwencel
Copy link

rwencel commented Jan 13, 2024

The contributing guidelines say PR's will probably won't be merged, so I'm not bothering to submit one, but I think this could be a possible fix in main.py's getsitepackages function if anybody ever wants to implement.

My problem was that the venv's lib path is capitalized as "Lib", but the regex uses lowercase. On Windows case doesn't matter, but on Unix it does, thus the conditional case sensitivity flag.

        paths_are_case_sensitive = os.path.normcase("Aa") == "Aa"
        flags = 0 if paths_are_case_sensitive else re.IGNORECASE
        pattern1 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'python[0-9.]+', 'site-packages']), flags)
        pattern2 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'site-packages']), flags)

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