-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ImportError: No module named functools_lru_cache #9344
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
Comments
Do you have a package called "backports" installed? Which version? This
might be a MacPorts packaging issue.
…On Tue, Oct 10, 2017 at 10:14 AM, Albert Z. Guo ***@***.***> wrote:
Bug report
*Bug summary*
upgraded matplotlib using MacPorts and found out that matplotlib now can't
be imported
*Code for reproduction*
import matplotlib
*Actual outcome*
Traceback (most recent call last):
File "/Users/Albert_Guo/Desktop/test_code.py", line 1, in <module>
import matplotlib
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 128, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 32, in <module>
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
*Expected outcome*
*Matplotlib version*
- Operating system: macOS Sierra Version: 10.12.6
- Matplotlib version: py27-matplotlib @2.1.0_1 (installed by MacPorts)
- Matplotlib backend (print(matplotlib.get_backend())): can't print
anything because matplotlib can't be imported at the first place
- Python version: python27 @2.7.14 (installed by MacPorts)
- Jupyter version (if applicable): py27-jupyter @1.0.0_1 (installed by
MacPorts)
- Other libraries:
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9344>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-KfTc9XyFTd2WmiXy9D0LrHIdDt3ks5sq3vMgaJpZM4P0AUW>
.
|
backports? Yes, I do have it. But the problem still exists. |
It backports various py3k features to python 2.7. It should have been
installed as a dependency for a 2.7 matplotlib install.
…On Tue, Oct 10, 2017 at 10:26 AM, Albert Z. Guo ***@***.***> wrote:
backports? No. What's it for?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9344 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-I5qA4MKOQK_lFnuq8woHWsCkUw9ks5sq36IgaJpZM4P0AUW>
.
|
I solved this problem. Thanks for the quick help @WeatherGod! I need to manually install another package named "py27-backports-functools_lru_cache" through MacPorts. I guess I shall move to Python 3 now. Python 2.7 seems to have more and more legacy compatibility problems these days. |
Indeed. I would also file a bug report with the MacPorts people to let them
know of the missing dependency.
…On Tue, Oct 10, 2017 at 10:38 AM, Albert Z. Guo ***@***.***> wrote:
I solved this problem. Thanks for the quick help @WeatherGod
<https://github.com/weathergod>!
I need to manually install another package named
"py27-backports-functools_lru_cache" through MacPorts.
I guess I shall move to Python 3 now. Python 2.7 seems to have more and
more legacy compatibility problems these days.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9344 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-E7le4IbLeoFCzqgx1ETipiS28zHks5sq4FZgaJpZM4P0AUW>
.
|
Can we re-open this issue, please? The problem re-surfaces (at least for me) when I pip install matplotlib 2.1.0 in a clean virtualenv. Regression to matplotlib 2.0.2 solves the problem. Ubuntu 17.04, virtualenv with python 2.7.13. |
@paulbrodersen What version of pip are you using? Starting from an empty venv works correctly for me:
Can you post your install log? |
This is getting more and more mysterious:
Setting up fresh virtualenv, installing matplotlib, ignoring cache:
ImportError:
|
It looks like you are pulling IPython from the system level but still importing some things from the venv. Also check what is in |
The first line of your output indicates what the problem likely is and how to fix it ;-) |
Installing ipython inside the venv has no effect:
ImportError:
|
I do have weird stuff in my
|
@jklymak Which line are you referring to? |
So the ipython you are calling is not in your virtualenv. In fact, as you can clearly see above, the versions are diferent; 5.4.1 is what you call, and 5.5.0 is what you installed. Unless you like banging your head against a wall or have some compelling use-case that precludes it, I strongly suggest using anaconda. I'm sure all that |
Ok. ipython does indeed seem to be the problem. I also noticed that ipython was still complaining about not being installed in the venv when I clearly had just installed it. That lead me to this issue, which suggests running |
Its possible (likely?) |
It seems unlikely that I would have had a matplotlib path already cached. I opened a new shell before initializing the venv. In my window manager (byobu) the hash table is empty when I initialize a new shell. Anyway, I am fairly happy now (albeit still confused). Thanks for all the help! |
It is most likely because the matplotlib that was being loaded was
associated with the environment that the other cached ipython.
…On Fri, Nov 24, 2017 at 11:47 AM, Paul Brodersen ***@***.***> wrote:
It seems unlikely that I would have had a matplotlib path already cached.
I opened a new shell before initializing the venv. In my window manager
(byobu) the hash table is empty when I initialize a new shell. Anyway, I am
fairly happy now (albeit still confused). Thanks for all the help!
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#9344 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-Nf8MEGqOMREwtYGq5p5y03uHJ5Eks5s5vM6gaJpZM4P0AUW>
.
|
come across with problem, after uninstall the matplotlib and install the privious version 2.0.2, the problem is solved |
Same as above: #9344 but I don't have anything funny in my path, I am not using a virtual environment and have installed everything using apt (I'm on Ubuntu 18.04). If I go back to matplotlib 2.0.2 using pip then it works, so I'm going with that for now, but I'd rather not use a billion installers. I'm having this problem with matplotlib 2.1+ too, but only with Python:
When I use iPython everything is peachy:
I am not at all sure what is causing this. I suspect there is some local vs system library thing going on. How do I fix this? Update:
It looks like importing pip changes at least the sys.path but I can't tell why what it is doing matters and how that relates to ipython. Update #2: The problem appears to be a path problem I am not sure how to solve. I use apt on Ubuntu 18.04 to install system modules into /usr/lib/python2.7/dist-packages/. This directory is where backports.functools_lru_cache lives. I also have some compiled modules installed in /usr/local/lib/python2.7/dist-packages/ where there is a backports module WITHOUT functools_lru_cache. The problem is that python is not following the system path and only seems to be looking in /usr/local/lib/python2.7/dist-packages/ for backports. However, ipython looks in both which is why ipython was working while python was not. python:
ipython:
Solution: To solve the problem I manually copied functools_lru_cache.py from /usr/lib/python2.7/dist-packages/backports/ to /usr/local/lib/python2.7/dist-packages/backports/. Now I can run matplotlib 2.2.2 no problem in python and ipython. It isn't clear to my why python and ipython are ignoring my request to reorder the path. My suspicion is that it has to do with backports being "built-in" now. I have another machine running 2.7.12 and it doesn't have this problem and backports isn't built in. ipython works because it looks in two places. |
@nadnerbity you idea is useful to me, I met the same error, both the os version and the dependencies packages are same with your's. Follow your way I fixed the error. |
In my case, I pip installed the package named "backports-functools_lru_cache" for MacOSX. |
Uninstall first |
I solved it by installing the following from the Ubuntu repos:
|
I updated to Ubuntu 19.04 and used this method to resolve. |
@sandrotosi This suggests that there is a bug in the py2 dependencies for the debian packaging? |
@tacaswell it's highly unlikely something in Debian is not ok with dependencies, as there would be people screaming all over the place and this is the first time i heard about this :) the OP is on Mac, and the 2 latest users look like they are using Ubuntu, which may have a more original way of handling dependencies due to their main/universe repos separations, but i cant comment on Ubuntu as i dont maintain the package there let me know if i can help in any way tho |
Ah, sorry to bother you @sandrotosi , I thought the debian -> ubuntu pipeline was more direct. https://bugs.launchpad.net/ubuntu/+source/matplotlib/+bug/1764823 For ubuntu it looks like there is an open issue about this problem (that is blamed an the |
ah yeah, when i first introduce |
This helped. Thanks!!! |
sudo apt install python-backports.functools-lru-cache it worked with me |
Bug report
Bug summary
upgraded matplotlib using MacPorts and found out that matplotlib now can't be imported
tried uninstall and reinstall matplotlib using MacPorts but the problem still exists
Code for reproduction
Actual outcome
Expected outcome
Matplotlib version
print(matplotlib.get_backend())
): can't print anything because matplotlib can't be imported at the first placeThe text was updated successfully, but these errors were encountered: