Closed shaief closed 11 years ago
Hi Shai.
Looks like the problem is in wrong type library loaded. Please try latest version from github. Or just replace code in installed package Python27\Lib\site-packages\pyautocad\api.py
:
import logging
import comtypes
import glob
import os
try:
import comtypes.client
# generate modules for work with ACAD constants
for pattern in ("acax*enu.tlb", "axdb*enu.tlb"):
pattern = os.path.join(
r"C:\Program Files\Common Files\Autodesk Shared",
pattern
)
tlib = glob.glob(pattern)[0]
comtypes.client.GetModule(tlib)
import comtypes.gen.AutoCAD as ACAD
except Exception:
# we are under readthedocs.org and need to mock this
ACAD = None
Also, what tool do you use for compiling your app to exe? If it's py2exe
and previous fix didn't work, Please try cx_Ffreeze.
Hi Roman, Thanks! Did you update it recently? i downloaded it a week ago from PyPi (https://pypi.python.org/pypi/pyautocad/). Should i use your gitHub repository? I did compile with cx_Freeze, and it works on my machine perfectly.
Shai.
I didn't update PyPI yet. Please check it on machine where you had problem when you can. If it works, I'll update PyPI package. Did previous version worked on your machine?
Previews version worked perfectly on my machine. I did as you suggested, and now i get the attached error. What did i do wrong?
It's strange.
What AutoCad version do you use? Do you have AutoCAD 20xx VBA module installed?
It all worked before, so i guess i have. I try it on AutoCAD 2009.
What is the best way to clean install your gitHub version?
What is the best way to clean install your gitHub version?
Delete Python27\Lib\site-packages\pyautocad\
download https://github.com/reclosedev/pyautocad/archive/master.zip unpack and run
python setup.py install
Also, delete comtypes cache
Python27\Lib\site-packages\comtypes\gen\
OK. Done that and stayed with the previous error. It is the machine that worked before, now i can't use the code here as well. That's weird.
Installation log:
C:\Users\-----\Desktop\pyautocad-master>python setup.py install
running install
running bdist_egg
running egg_info
creating pyautocad.egg-info
writing requirements to pyautocad.egg-info\requires.txt
writing pyautocad.egg-info\PKG-INFO
writing top-level names to pyautocad.egg-info\top_level.txt
writing dependency_links to pyautocad.egg-info\dependency_links.txt
writing manifest file 'pyautocad.egg-info\SOURCES.txt'
reading manifest file 'pyautocad.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'AUTHORS'
warning: no previously-included files matching '*.pyc' found under directory 'do
cs'
warning: no previously-included files matching '*.pyo' found under directory 'do
cs'
no previously-included directories found matching 'docs\_build'
no previously-included directories found matching 'docs\_themes\.git'
writing manifest file 'pyautocad.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build\lib
creating build\lib\pyautocad
copying pyautocad\api.py -> build\lib\pyautocad
copying pyautocad\cache.py -> build\lib\pyautocad
copying pyautocad\types.py -> build\lib\pyautocad
copying pyautocad\utils.py -> build\lib\pyautocad
copying pyautocad\__init__.py -> build\lib\pyautocad
creating build\lib\pyautocad\contrib
copying pyautocad\contrib\tables.py -> build\lib\pyautocad\contrib
copying pyautocad\contrib\__init__.py -> build\lib\pyautocad\contrib
creating build\bdist.win32
creating build\bdist.win32\egg
creating build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\api.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\cache.py -> build\bdist.win32\egg\pyautocad
creating build\bdist.win32\egg\pyautocad\contrib
copying build\lib\pyautocad\contrib\tables.py -> build\bdist.win32\egg\pyautocad
\contrib
copying build\lib\pyautocad\contrib\__init__.py -> build\bdist.win32\egg\pyautoc
ad\contrib
copying build\lib\pyautocad\types.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\utils.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\__init__.py -> build\bdist.win32\egg\pyautocad
byte-compiling build\bdist.win32\egg\pyautocad\api.py to api.pyc
byte-compiling build\bdist.win32\egg\pyautocad\cache.py to cache.pyc
byte-compiling build\bdist.win32\egg\pyautocad\contrib\tables.py to tables.pyc
byte-compiling build\bdist.win32\egg\pyautocad\contrib\__init__.py to __init__.p
yc
byte-compiling build\bdist.win32\egg\pyautocad\types.py to types.pyc
byte-compiling build\bdist.win32\egg\pyautocad\utils.py to utils.pyc
byte-compiling build\bdist.win32\egg\pyautocad\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INF
O
copying pyautocad.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist\pyautocad-0.1.2-py2.7.egg' and adding 'build\bdist.win32\egg' to
it
removing 'build\bdist.win32\egg' (and everything under it)
Processing pyautocad-0.1.2-py2.7.egg
creating c:\python27\lib\site-packages\pyautocad-0.1.2-py2.7.egg
Extracting pyautocad-0.1.2-py2.7.egg to c:\python27\lib\site-packages
Adding pyautocad 0.1.2 to easy-install.pth file
Installed c:\python27\lib\site-packages\pyautocad-0.1.2-py2.7.egg
Processing dependencies for pyautocad==0.1.2
Searching for comtypes
Reading http://pypi.python.org/simple/comtypes/
Reading http://starship.python.net/crew/theller/wiki/the_comtypes_package
Reading http://sourceforge.net/project/showfiles.php?group_id=115265
Reading http://starship.python.net/crew/theller/comtypes
Reading http://starship.python.net/crew/wiki/the_comtypes_package
Best match: comtypes dev
Downloading https://comtypes.svn.sourceforge.net/svnroot/comtypes/#egg=comtypes-
dev
Doing subversion checkout from https://comtypes.svn.sourceforge.net/svnroot/comt
ypes/ to c:\users\shai\appdata\local\temp\easy_install-lsax6k\comtypes
'svn' is not recognized as an internal or external command,
operable program or batch file.
Processing comtypes
error: Couldn't find a setup script in c:\users\shai\appdata\local\temp\easy_ins
tall-lsax6k\comtypes
Looks like comtypes setup is kinda broken (it links to svn version of package).
Try to comment out comtypes requirement in setup.py
install_requires=[
#'comtypes',
],
And if you are trying to run compiled exe, delete
c:\Users\%USERNAME%\AppData\Local\Temp\comtypes_cache\
directory
Did it, and still the same error while running my code.
The installation log is:
C:\Users\-----\Desktop\pyautocad-master>python setup.py install
running install
running bdist_egg
running egg_info
writing pyautocad.egg-info\PKG-INFO
writing top-level names to pyautocad.egg-info\top_level.txt
writing dependency_links to pyautocad.egg-info\dependency_links.txt
reading manifest file 'pyautocad.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'AUTHORS'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
no previously-included directories found matching 'docs\_build'
no previously-included directories found matching 'docs\_themes\.git'
writing manifest file 'pyautocad.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
copying pyautocad\api.py -> build\lib\pyautocad
copying pyautocad\cache.py -> build\lib\pyautocad
copying pyautocad\types.py -> build\lib\pyautocad
copying pyautocad\utils.py -> build\lib\pyautocad
copying pyautocad\__init__.py -> build\lib\pyautocad
copying pyautocad\contrib\tables.py -> build\lib\pyautocad\contrib
copying pyautocad\contrib\__init__.py -> build\lib\pyautocad\contrib
creating build\bdist.win32\egg
creating build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\api.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\cache.py -> build\bdist.win32\egg\pyautocad
creating build\bdist.win32\egg\pyautocad\contrib
copying build\lib\pyautocad\contrib\tables.py -> build\bdist.win32\egg\pyautocad\contrib
copying build\lib\pyautocad\contrib\__init__.py -> build\bdist.win32\egg\pyautocad\contrib
copying build\lib\pyautocad\types.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\utils.py -> build\bdist.win32\egg\pyautocad
copying build\lib\pyautocad\__init__.py -> build\bdist.win32\egg\pyautocad
byte-compiling build\bdist.win32\egg\pyautocad\api.py to api.pyc
byte-compiling build\bdist.win32\egg\pyautocad\cache.py to cache.pyc
byte-compiling build\bdist.win32\egg\pyautocad\contrib\tables.py to tables.pyc
byte-compiling build\bdist.win32\egg\pyautocad\contrib\__init__.py to __init__.pyc
byte-compiling build\bdist.win32\egg\pyautocad\types.py to types.pyc
byte-compiling build\bdist.win32\egg\pyautocad\utils.py to utils.pyc
byte-compiling build\bdist.win32\egg\pyautocad\__init__.py to __init__.pyc
creating build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying pyautocad.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist\pyautocad-0.1.2-py2.7.egg' and adding 'build\bdist.win32\egg' to
it
removing 'build\bdist.win32\egg' (and everything under it)
Processing pyautocad-0.1.2-py2.7.egg
creating c:\python27\lib\site-packages\pyautocad-0.1.2-py2.7.egg
Extracting pyautocad-0.1.2-py2.7.egg to c:\python27\lib\site-packages
Adding pyautocad 0.1.2 to easy-install.pth file
Installed c:\python27\lib\site-packages\pyautocad-0.1.2-py2.7.egg
Processing dependencies for pyautocad==0.1.2
Finished processing dependencies for pyautocad==0.1.2
It's weird. I'd try to restart AutoCAD or/and to use PyPI version.
Oh, my bad. After installing the new version my AutoCAD was closed. I now opened it and it works.
Sorry!
Now i'll re-compile it and try on the other machines. I'll update if it will work.
Thanks a lot for your help and for the library!
Hi Roman, Here is an update: I still face the same error on three out of five computers running the compiled version of my code.
Do you have any idea what can cause this issue?
Thanks!
Shai.
Sorry, can't reproduce this issue. But I've tested compiled version only on following configurations: WinXP 32bit, Autocad 2008 Win7 32bit, Autocad 2013 Win7 64bit, Autocad 2013
Hi Roman, Well, it was an issue with my compilation. I didn't take into consideration differences between 64bit and 32bit systems, as i was initially compiling it on 64bit. Sorry for the hassle, i'm closing this issue.
Thanks a lot!
Shai.
Hi Roman, First of all - thank you so much for this library. It is working great and allows me to do what i wanted just in Python. I wrote a simple script (with gui) and it worked well on my machine, but after compiling i tried it on two different machines and received an error. Here is a version of the error from each of the machines:
Here is the code i used:
and a trace back attached as an image.
Do you have any idea what went wrong?
Thanks,
Shai.