storborg / pyweaving

Python Weaving Tools
Other
17 stars 10 forks source link

ImportError when calling #1

Closed duncabar closed 8 years ago

duncabar commented 8 years ago

Hi Scott,

Firstly, thanks for making your library available in open source and for contributing to the community!

I'm not a Python developer (and this might be the problem) but i am getting an error when calling if i try the following: pyweaving render scarf.wif

Note the last error PDFRenderer. I saw a note that you'd removed this in favor of SVG. Do I simply have something setup wrong? I used pip to install.. but I also do not seem to be able to call it directly from within an interpreter. I tried the VS 2015 Python Interpreter as well as a couple others. Can you point me in the right direction?

Kind Regards,

Barry

Traceback (most recent call last): File "C:\dev\Python\Python35\Scripts\pyweaving-script.py", line 9, in load_entry_point('pyweaving==0.0.5', 'console_scripts', 'pyweaving')() File "c:\dev\python\python35\lib\site-packages\pkg_resourcesinit.py", line 558, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "c:\dev\python\python35\lib\site-packages\pkg_resourcesinit.py", line 2682, in load_entry_point return ep.load() File "c:\dev\python\python35\lib\site-packages\pkg_resourcesinit.py", line 2355, in load return self.resolve() File "c:\dev\python\python35\lib\site-packages\pkg_resourcesinit.py", line 2361, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "c:\dev\python\python35\lib\site-packages\pyweaving\cmd.py", line 9, in from .render import ImageRenderer, SVGRenderer, PDFRenderer ImportError: cannot import name 'PDFRenderer'

storborg commented 8 years ago

Thanks for the heads up: this is my fault, I removed that import but forgot to publish a new release. I've just put out a new version. You should be able to switch to it with just pip install --upgrade pyweaving.

duncabar commented 8 years ago

Thanks Scott! That fixed that issue. Now it looks like I have a font related error. I will try to track that one down this evening. I saw some similar issues on stack overflow so i should be able to work that out. I'll post back when i do.

C:\dev\pyweaving-master\pyweaving>pyweaving render scarf.wif Traceback (most recent call last): File "C:\dev\Python\Python35\Scripts\pyweaving-script.py", line 9, in load_entry_point('pyweaving==0.0.7', 'console_scripts', 'pyweaving')() File "c:\dev\python\python35\lib\site-packages\pyweaving\cmd.py", line 135, in main return opts.function(opts) File "c:\dev\python\python35\lib\site-packages\pyweaving\cmd.py", line 32, in render ImageRenderer(draft).show() File "c:\dev\python\python35\lib\site-packages\pyweaving\render.py", line 55, in init self.font = ImageFont.truetype(font_path, self.font_size) File "c:\dev\python\python35\lib\site-packages\PIL\ImageFont.py", line 239, in truetype return FreeTypeFont(font, size, index, encoding) File "c:\dev\python\python35\lib\site-packages\PIL\ImageFont.py", line 128, in init self.font = core.getfont(font, size, index, encoding) OSError: cannot open resource

storborg commented 8 years ago

Great. Re: the font issue, it looks like that could actually be a problem with the way I've setup the Python package, resulting in an issue with Windows usage. Let me know if you find a solution, I'll take a look as well. Sorry for all the issues.

duncabar commented 8 years ago

Thanks again Scott. I was able to get around the problem by moving Arial.ttf out of the c:\windows\fonts directory and putting it in the site-packages folder and directly setting font_path. I know this is inelegant but it worked for now. Thinking this could be a Windows 10 permissions issue but I'll post a better workaround later.

#font_path = os.path.join(__here__, 'data', 'Arial.ttf')
font_path = 'C:\dev\Python\Python35\Lib\site-packages\pyweaving\Arial.ttf'

I am a c# developer so now my next decision is whether to just learn Python or perhaps see if this will work in IronPython and dotNet.

Thanks again!