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 named 'regex._regex'; 'regex' is not a package #1207

Closed
jonasrk opened this issue Dec 16, 2019 · 20 comments · Fixed by #1209
Closed

No module named 'regex._regex'; 'regex' is not a package #1207

jonasrk opened this issue Dec 16, 2019 · 20 comments · Fixed by #1209
Labels
T: bug Something isn't working

Comments

@jonasrk
Copy link

jonasrk commented Dec 16, 2019

Traceback (most recent call last):
File "/usr/local/bin/black", line 5, in
from black import patched_main
File "/usr/local/lib/python3.8/site-packages/black.py", line 15, in
import regex as re
File "/usr/local/lib/python3.8/site-packages/regex.py", line 402, in
import _regex_core
File "/usr/local/lib/python3.8/site-packages/_regex_core.py", line 21, in
import regex._regex as _regex
ModuleNotFoundError: No module named 'regex._regex'; 'regex' is not a package

@jonasrk jonasrk added the T: bug Something isn't working label Dec 16, 2019
@daviddavis
Copy link

I'm hitting the same thing. I can reproduce this without black too just by opening a repl:

>>> import regex as re
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/regex.py", line 402, in <module>
    import _regex_core
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/_regex_core.py", line 21, in <module>
    import regex._regex as _regex
ModuleNotFoundError: No module named 'regex._regex'; 'regex' is not a package

@jonasrk
Copy link
Author

jonasrk commented Dec 16, 2019

@daviddavis So it's the fault of https://pypi.org/project/regex/ ?

Update: I've created https://bitbucket.org/mrabarnett/mrab-regex/issues/349/no-module-named-regex_regex-regex-is-not-a - just in case.

@daviddavis
Copy link

daviddavis commented Dec 16, 2019

Yea, if I pin regex==2019.11.1, everything works fine. So I think it's regex 2019.12.9.

@bavedarnow
Copy link

bavedarnow commented Dec 16, 2019

Looks like they were doing some work recently that may have caused this: https://bitbucket.org/mrabarnett/mrab-regex/commits/all

Black isn't pinned to any specific version of regex: https://github.com/psf/black/blob/master/setup.py#L72

@mikegrima
Copy link

@TomFaulkner
Copy link

Will there be a release for this fix? Timeframe?

If not I can pin the requirement in my team's requirements file, just want to know whether I should or just wait a bit.

@basnijholt
Copy link

basnijholt commented Dec 16, 2019

Getting the same thing on Azure.

Anyone knows what changed?

Seems like a new patch release of black is needed.

Edit: according to the author of regex its

The Linux wheels are a result of issue #343.

@vilhelmprytz
Copy link

Also have the same issue. What happened?

@VolodymyrPavliukevych
Copy link

Have the same on Google Cloud App engine

@TomFaulkner
Copy link

Also have the same issue. What happened?

regex isn't pinned to a particular version. Apparently something in that library changed with their most recent release.

progwriter pushed a commit to progwriter/pybatfish that referenced this issue Dec 16, 2019
@JelleZijlstra
Copy link
Collaborator

@TomFaulkner regex is the project that caused the breakage here (see the messages above that identified the issue), so it's the one that needs fixing.

I'd accept a PR to pin Black's dependency to a non-broken version of regex, but I can't promise an immediate release of Black.

@frenck

This comment has been minimized.

@JelleZijlstra
Copy link
Collaborator

No need for additional comments saying that yet more people hit this issue.

@TomFaulkner
Copy link

@TomFaulkner regex is the project that caused the breakage here (see the messages above that identified the issue), so it's the one that needs fixing.

I'd accept a PR to pin Black's dependency to a non-broken version of regex, but I can't promise an immediate release of Black.

I appreciate the response.

progwriter pushed a commit to progwriter/pybatfish that referenced this issue Dec 16, 2019
progwriter pushed a commit to progwriter/pybatfish that referenced this issue Dec 16, 2019
dmerejkowsky added a commit to pyenchant/pyenchant that referenced this issue Dec 16, 2019
daviddavis pushed a commit to daviddavis/black that referenced this issue Dec 16, 2019
Pin the regex dependency to the last known good release. I would use a y
release but it doesn't appear that regex is using sematic versioning.
Also, it appears that the 2019.12.9 release may have issues (although it
could just be improper packaging of the wheel). See related issue
psf#1207.
@daviddavis
Copy link

daviddavis commented Dec 16, 2019

I'd accept a PR to pin Black's dependency to a non-broken version of regex, but I can't promise an immediate release of Black.

Understood. I opened #1208 in hopes of preventing future breakages when a new regex is released.

@florimondmanca
Copy link

florimondmanca commented Dec 16, 2019

FWIW, another user-side workaround that does not require a new release of Black nor regex is to force pip to not use binary wheels from regex when installing Black:

$ pip install black --no-binary=regex

Also works in a requirements.txt file:

black --no-binary=regex

daviddavis pushed a commit to daviddavis/black that referenced this issue Dec 16, 2019
Pin the regex dependency to the last known good release. I would use a y
release but it doesn't appear that regex is using sematic versioning.
Also, it appears that the 2019.12.9 release may have issues (although it
could just be improper packaging of the wheel). See related issue
psf#1207.
@hugovk
Copy link
Contributor

hugovk commented Dec 16, 2019

I'd accept a PR to pin Black's dependency to a non-broken version of regex, but I can't promise an immediate release of Black.

Understood. I opened #1208 in hopes of preventing future breakages when a new regex is released.

Sorry, I hadn't seen your PR, but please see #1209 for an alternative approach.

@frenck
Copy link

frenck commented Dec 16, 2019

Our builds started working again, it looks like the issue is addressed at regex.

https://bitbucket.org/mrabarnett/mrab-regex/issues/343/wheel-for-linux#comment-55284973

hudeven added a commit to hudeven/pytext that referenced this issue Dec 16, 2019
Summary:
CircleCI failed due to a recent change in regex, black detected it and broke the CircleCI
psf/black#1207

Workaround: pin regex version to last working version

Differential Revision: D19129020

fbshipit-source-id: c4277ff3f59930bcbcce5ce13e26214963d9a80f
facebook-github-bot pushed a commit to facebookresearch/pytext that referenced this issue Dec 16, 2019
Summary:
Pull Request resolved: #1199

CircleCI failed due to a recent change in regex, black detected it and broke the CircleCI
psf/black#1207

Workaround: pin regex version to last working version

Reviewed By: hikushalhere, m3rlin45

Differential Revision: D19129020

fbshipit-source-id: f17cd32d4424f33482c482bb07d9e0e7a807240b
lucaslavandeira added a commit to datosgobar/series-tiempo-ar that referenced this issue Dec 17, 2019
@zsol zsol closed this as completed Feb 3, 2020
thekaveman added a commit to cal-itp/transitstacks that referenced this issue Jun 22, 2021
mhausenblas/mkdocs-deploy-gh-pages needs a requirements file, else it
tries to install the repo-level requirements, which typically are not
needed for the docs site, see:
mhausenblas/mkdocs-deploy-gh-pages#53

introduce requirements file specific to the docs site, fixing an issue
with trying to install the dev-requirements.txt

the underlying issue was with trying to install black into the Docker
image used by this GitHub Action (squidfunk/mkdocs-material:7.1.8), see:
https://github.com/mhausenblas/mkdocs-deploy-gh-pages/blob/master/Dockerfile

recent versions of black depend on regex, which has a history of trouble
with Linux wheel availability and support

* psf/black#1207
* https://bitbucket.org/mrabarnett/mrab-regex/issues/343/wheel-for-linux
* https://bitbucket.org/mrabarnett/mrab-regex/issues/349/no-module-named-regex_regex-regex-is-not-a

the Docker image does not have gcc available; rather than installing a
build chain to build regex to enable the install of black, which isn't
even used by the docs site, the simpler fix was to create a
docs/requirements.txt and point the GitHub Action at it instead

similar report on the Action repo:
mhausenblas/mkdocs-deploy-gh-pages#105
@idan92
Copy link

idan92 commented Apr 4, 2022

You can try reinstalling the regex.
$ pip uninstall regex
$ pip install regex

or just
$ pip install --force-reinstall regex

works for me :)

@davedx
Copy link

davedx commented Jun 20, 2022

I also encountered this issue and none of the various pip commands in this thread or elsewhere on the Internet helped. I was using a new Macbook Pro with the default python 3.8 installation. I wrote the steps I took to fix it here: mrabarnett/mrab-regex#413 (comment)

jl-applied added a commit to AppliedIntuition/black that referenced this issue Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.