11

I am using wxpython and matplotlib to develop a software, when I complete my work, I want to convert the python files to *.exe file by py2exe, so it can be used in Windows. Here is the setup.py file.

from distutils.core import setup  
import py2exe  
import sys  
includes = ["encodings", "encodings.*"]    
sys.argv.append("py2exe")  
options = {"py2exe":   { "bundle_files": 1 ,"dll_excludes":["MSVCP90.dll"]}}   
setup(options = options,  
      zipfile=None,   
      console = [{"script":'test.py'}])

Then I executed this script by python setup.py to generate test.exe,and it worked.

When I executed test.exe there post an error ImportError: No module named cycler

And then, I try to execute import cycler in python shell, and there is no error occur. Also, I checked the python directory c:/python27/Lib/site-packages/, and the cycler-0.9.0-py2.7.egg file exists here.

How to deal with this problem.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Elivis
  • 307
  • 1
  • 6
  • 18
  • Same error here but got it after trying to run some matplotlib code on a Debian system. – Carl Dec 11 '15 at 21:38

3 Answers3

9

In case you are using anaconda, use:

conda install cycler
Prakhar Agarwal
  • 2,724
  • 28
  • 31
  • Thanks, this worked for me whereas others (including conda forge) reported condition as satisfied, however, I will mention for benefit of others that PIP install revealed that cython was not installed so this was added pre conda install. Not sure if that made a difference or not, any comments that help me understand more about this much appreciated, thanks. – scatter Jun 16 '18 at 11:48
  • 1
    FYI: I tried 'conda install cycler', but did not work. But, 'pip install cycler' did. – jtam Nov 09 '18 at 21:21
7

matplotlib calls cycler and it seems cycler has not been introduced to matplotlib, which is the cause of the above error.

To fix this issue just open Terminal (or command prompt) and try to run the command

$ sudo pip install cycler if you have pip installed

OR

$ sudo easy_install -U cycler if you have easy_install installed.

If this command is successfully executed, it should look like matplotlib can use it.

Even I had this problem, when I executed this command my problem got solved.

Farooque
  • 3,616
  • 2
  • 29
  • 41
0

On an HPC environment, I solved this problem by uninstalling the local version of matplotlib which was superseding the globally installed version,

$pip3 uninstall matplotlib

  • Hello! Would you mind expanding a bit on your answer? E.g. show how to check whether this is the actual problem (check if matplotlib is installed locally and/or globally) and show how you could reinstall it locally. Possibly I'd also include a sentence or two about virtual environments :) – Andreas Storvik Strauman Apr 11 '21 at 09:37