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

svg2mod.py is not working on Windows #23

Open
jorgegarciamateos opened this issue Mar 9, 2018 · 17 comments
Open

svg2mod.py is not working on Windows #23

jorgegarciamateos opened this issue Mar 9, 2018 · 17 comments

Comments

@jorgegarciamateos
Copy link

Hello. I'm new ussing svg2mod.py. I am on Windows 10 and Python 3.6. I cloned your repo and generated a file named "led_array_txt.svg" in inkspace, in a layer named SilkS. I typed in a terminal:

C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod>svg2mod.py -i led_array_txt.svg -p 1 -f 0.94
And the result was:

Traceback (most recent call last):
File "C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
File "C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
ModuleNotFoundError: No module named 'svg2mod.svg'; 'svg2mod' is not a package

Of course, no file .mod was generated. Could you help me, please?

Even if I run:
C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod>svg2mod.py --help
The result is the same:
Traceback (most recent call last):
File "C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
File "C:\Users\Jorge\Documents\Kicad\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
ModuleNotFoundError: No module named 'svg2mod.svg'; 'svg2mod' is not a package

I'm lost...

@badgeek
Copy link

badgeek commented Apr 3, 2018

i developed inkscape extension to convert drawing to kicad, it works on windows too

https://github.com/badgeek/svg2shenzhen-next

@kylenahas
Copy link

Hi @jorgegarciamateos ,

You first need to run the setup.py script located at the root directory of this project like such:

python setup.py install

Also, @badgeek, this really isn't the place to promote your project.

@badgeek
Copy link

badgeek commented Apr 4, 2018

@kylenahas hi kyle, sorry i thought that this project is not maintained anymore, with much respect i learn a lot from svg2mod

thank you!

@EsserPrototyping
Copy link

Can somebody give me an example how to execute the script? ..or installation guide?
With the older release it worked by calling "python svg2mod.py" from the svg2mod-master folder.
With the newer release it is missing the svg.py ..and i did not found any way to include it.
I now installed phyton365.. installed the script with "python setup.py install" but now i get the same error as jorgegarciamateos described.
I noticed that after installing the setup there is a svg2mod-script.py in the Scripts-folder.. so i tried to start the script there, but then i get "AttributeError: ´dict´ object has no attribute ´iteritems´ "
I dont know much about python and sorry for spamming this post. Im shure its my fault but i need to get this working again..

@zirafa
Copy link

zirafa commented May 9, 2018

Also having a lot of trouble with this, and I'm running via Terminal on Mac OSX 10.11.6.

Here are the various methods I attempted:

SETUP.PY method

After running python setup.py install trying to run svg2mod.py fails with the error:

ModuleNotFoundError: No module named 'svg2mod.svg'; 'svg2mod' is not a package

PIP method

Tried to install via PIP: pip install git+https://github.com/mtl/svg2mod

Installation is successful, but trying to run the binary on the provided example svg also fails:

$ svg2mod -i dt-logo.svg
Parsing SVG...
No handler for element {http://www.w3.org/2000/svg}defs
No handler for element {http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}namedview
No handler for element {http://www.w3.org/2000/svg}metadata
transform: translate [-1.4586893e-06, 1.189826]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/svg2mod", line 11, in <module>
    load_entry_point('svg2mod==0.1.0', 'console_scripts', 'svg2mod')()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg2mod.py", line 1450, in <module>
    main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg2mod.py", line 40, in main
    args.module_value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg2mod.py", line 448, in __init__
    self.svg = svg.parse( file_name )
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg/svg/__init__.py", line 6, in parse
    f = svg.Svg(filename)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg/svg/svg.py", line 210, in __init__
    self.parse(filename)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg/svg/svg.py", line 239, in parse
    top_group.append(self.root)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg/svg/svg.py", line 286, in append
    item = elt_class(elt)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/svg2mod/svg/svg/svg.py", line 265, in __init__
    for id, value in elt.attrib.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

The commits in PR #18 rearranged the folder structure and changed how the svg module was imported in svg2mod.py.

However with both install methods the SVG dependency appears to be broken, or there is some additional documentation missing around how to install this properly.

@zirafa
Copy link

zirafa commented May 9, 2018

I've narrowed down the issue to Python version. Currently svg2mod is only compatible with Python2 environments. If you are running Python3, svg2mod in its current form will not work due to the deprecation of the following methods:

Built-in changes for Python 3:

Remove dict.iteritems(), dict.iterkeys(), and dict.itervalues().
    Instead: use dict.items(), dict.keys(), and dict.values() respectively. 

After updating these methods in svg2mod.py and svg.py, I was able to get the script to work, but only when installed via pip3. Manually building via setup.py install still fails...

I created a fork that is compatible with python3 here if anybody wants to try it, and opened a separate issue about the svg dependency problem.

@boelle
Copy link

boelle commented Jan 17, 2019

i have the same problem and i did run the installer

C:\Users\boher\Downloads\svg2mod-master\svg2mod-master>setup.py install
running install
running bdist_egg
running egg_info
creating svg2mod.egg-info
writing svg2mod.egg-info\PKG-INFO
writing top-level names to svg2mod.egg-info\top_level.txt
writing dependency_links to svg2mod.egg-info\dependency_links.txt
writing entry points to svg2mod.egg-info\entry_points.txt
writing manifest file 'svg2mod.egg-info\SOURCES.txt'
reading manifest file 'svg2mod.egg-info\SOURCES.txt'
writing manifest file 'svg2mod.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\svg2mod
copying svg2mod\svg2mod.py -> build\lib\svg2mod
copying svg2mod\__init__.py -> build\lib\svg2mod
creating build\lib\svg2mod\svg
copying svg2mod\svg\__init__.py -> build\lib\svg2mod\svg
creating build\lib\svg2mod\svg\svg
copying svg2mod\svg\svg\geometry.py -> build\lib\svg2mod\svg\svg
copying svg2mod\svg\svg\svg.py -> build\lib\svg2mod\svg\svg
copying svg2mod\svg\svg\__init__.py -> build\lib\svg2mod\svg\svg
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\svg2mod
creating build\bdist.win-amd64\egg\svg2mod\svg
creating build\bdist.win-amd64\egg\svg2mod\svg\svg
copying build\lib\svg2mod\svg\svg\geometry.py -> build\bdist.win-amd64\egg\svg2mod\svg\svg
copying build\lib\svg2mod\svg\svg\svg.py -> build\bdist.win-amd64\egg\svg2mod\svg\svg
copying build\lib\svg2mod\svg\svg\__init__.py -> build\bdist.win-amd64\egg\svg2mod\svg\svg
copying build\lib\svg2mod\svg\__init__.py -> build\bdist.win-amd64\egg\svg2mod\svg
copying build\lib\svg2mod\svg2mod.py -> build\bdist.win-amd64\egg\svg2mod
copying build\lib\svg2mod\__init__.py -> build\bdist.win-amd64\egg\svg2mod
byte-compiling build\bdist.win-amd64\egg\svg2mod\svg\svg\geometry.py to geometry.pyc
byte-compiling build\bdist.win-amd64\egg\svg2mod\svg\svg\svg.py to svg.pyc
byte-compiling build\bdist.win-amd64\egg\svg2mod\svg\svg\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\svg2mod\svg\__init__.py to __init__.pyc
byte-compiling build\bdist.win-amd64\egg\svg2mod\svg2mod.py to svg2mod.pyc
byte-compiling build\bdist.win-amd64\egg\svg2mod\__init__.py to __init__.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\entry_points.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
copying svg2mod.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
creating dist
creating 'dist\svg2mod-0.1.0-py2.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing svg2mod-0.1.0-py2.7.egg
creating c:\users\boher\.platformio\python27\lib\site-packages\svg2mod-0.1.0-py2.7.egg
Extracting svg2mod-0.1.0-py2.7.egg to c:\users\boher\.platformio\python27\lib\site-packages
Adding svg2mod 0.1.0 to easy-install.pth file
Installing svg2mod-script.py script to C:\Users\boher\.platformio\python27\Scripts
Installing svg2mod.exe script to C:\Users\boher\.platformio\python27\Scripts

Installed c:\users\boher\.platformio\python27\lib\site-packages\svg2mod-0.1.0-py2.7.egg
Processing dependencies for svg2mod==0.1.0
Finished processing dependencies for svg2mod==0.1.0

C:\Users\boher\Downloads\svg2mod-master\svg2mod-master>

C:\Users\boher\Downloads\svg2mod-master\svg2mod-master\svg2mod>svg2mod.py -i logo.svg -o logo.kicad_mod -d 600
Traceback (most recent call last):
File "C:\Users\boher\Downloads\svg2mod-master\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
File "C:\Users\boher\Downloads\svg2mod-master\svg2mod-master\svg2mod\svg2mod.py", line 10, in
import svg2mod.svg as svg
ImportError: No module named svg

C:\Users\boher\Downloads\svg2mod-master\svg2mod-master\svg2mod>

@zirafa
Copy link

zirafa commented Jan 17, 2019

@boelle The reason that method doesn't work is detailed in #24. For python2 you can try installing via pip or pip2 command: pip2 install git+https://github.com/mtl/svg2mod

A summary of current python & installation problems can be found in #33.

@boelle
Copy link

boelle commented Jan 17, 2019

i will read those 2, but i asume your suggestions are meant for windows?

@boelle
Copy link

boelle commented Jan 17, 2019

btw running python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40)
i think its installed as a part of inkscape or some of the other programs i installed

@zirafa
Copy link

zirafa commented Jan 17, 2019

@boelle for python 2.7 try running pip install git+https://github.com/mtl/svg2mod

@boelle
Copy link

boelle commented Jan 17, 2019

not right syntax

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pip install git+https://github.com/mtl/svg2mod
  File "<stdin>", line 1
    pip install git+https://github.com/mtl/svg2mod
              ^
SyntaxError: invalid syntax
>>>

@boelle
Copy link

boelle commented Jan 17, 2019

remember i'm on windows and not linux

@zirafa
Copy link

zirafa commented Jan 17, 2019

You want to run that in your shell command prompt, not in Python. If it still doesn't work, you may need to install pip.

@boelle
Copy link

boelle commented Jan 17, 2019

hehe, there should be an online thing for this, much less trouble for the user

this will be a task for tomorrow

@ghost
Copy link

ghost commented Sep 19, 2019

It would be nice to add the "python setup.py install" command to the documentation. I mean, how everyone is supposed to know ?

@ghost
Copy link

ghost commented Sep 19, 2019

Also, the line "import svg2mod.svg as svg" crashes.
It works if I copy the files from the "svg/svg" folder to the same folder as the svg2mod.py, then replacing the import line by "import svg".
Simple enough.

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

6 participants