python 3.2: cx_freeze does not import all of pyserial - python

I am having issues building an exe verision of my python 3.2 script. The script requires pyserial and builds using cx_freeze. However, when I run the exe I get:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27,
in <module>
exec(code, m.__dict__)
File "my_serial_program.py", line 1, in <module>
import serial
File "C:\Python32\lib\site-packages\serial\__init__.py", line 19, in <module>
from .serialwin32 import *
File "C:\Python32\lib\site-packages\serial\serialwin32.py", line 12, in <module>
from . import win32
ImportError: cannot import name win32
Doing a little snooping, Pyserial site-package has a "win32.py" module (in addition to serialwin32.py); however, in the compressed lib that cx_freeze produces, win32.py is missing. Simply placing a pyc version does not fix the issue. Also using cx_freeze "includes = [ ]" does not work.
Any ideas? Is my question even cogent (I am fairly new to python)?

I had the same issue. There is an option to include extra modules as mentioned in cx_Freeze ImportError: cannot import name and documentation for cx_Freeze
Just append --include-modules serial.win32

Related

Python can't load libc when importing xfsm module

I'm trying to write Python code to manipulate Xerox FST files, and I've installed the Python bindings for libxfsm and the XFSM library available through http://fsmbook.com. I'm running 64-bit Ubuntu. The installation goes fine, but when I try to import the xfsm module, I get this error:
>>> import xfsm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/xfsm/__init__.py", line
30, in <module>
import xfsm.errors # So error handler gets installed
File "/usr/local/lib/python2.7/dist-packages/xfsm/errors.py", line
8, in <module>
from xfsm.utils import *
File "/usr/local/lib/python2.7/dist-packages/xfsm/utils.py", line
39, in <module>
libc = cfsm.load_library("c")
File "/usr/local/lib/python2.7/dist-packages/xfsm/cfsm_api.py", line
366, in l oad_library
raise ImportError("%s not found." % libname)
ImportError: c not found.
Inspecting the source code for the Python interface, it looks like it is trying and failing to find libc, and failing, but I am at a loss on how to fix that.
Has anybody else gotten the Python-XFST interface working, or have any idea what's going wrong and how to fix it?
I had same problem on 64-bit Ubuntu 14.04. The problem is it can't find libc. In my case libc on my OS is name libc.so.6(I don't know why, I am new on Ubuntu). But the Python-XFST doesn't recognize it (Detail your can refer to source file)
My solution is simple, just modify xfsm/utils.py file in
**Line 39** : libc = cfsm.load_library("c")
to
**Line 39** : libc = cfsm.load_library("libc.so.6")
Remember to add the path to libc.so.6 in env.

Python error: No module named RuntimeError

Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module

No module named weight_vector in sci with py2exe in windows

I get the following error message using Python v2.7.5 and scipy v0.12.0 with py2exe v0.6.9 on a 32 bit machine using 32 bit versions of the packages from Christoph Gohlke. If anyone can provide relevant and useful suggestions I would greatly appreciate it. Here is the error message:
Traceback (most recent call last):
File "MainWindow.py", line 13, in <module>
from svm.svm import SVM
File "svm\svm.pyc", line 4, in <module>
File "sklearn\svm\__init__.pyc", line 13, in <module>
File "sklearn\svm\classes.pyc", line 3, in <module>
File "sklearn\linear_model\__init__.pyc", line 20, in <module>
File "sklearn\linear_model\sgd_fast.pyc", line 12, in <module>
File "sklearn\linear_model\sgd_fast.pyc", line 10, in __load
File "weight_vector.pxd", line 14, in init sklearn.linear_model.sgd_fast
(sklearn\linear_model\sgd_fast.c:13206)
ImportError: No module named weight_vector
This is my setup.py file:
from distutils.core import setup
import py2exe
import sys
sys.path.append('../')
dcm = 'dcm.testDCM'
svm_path = 'svm.svm'
setup(windows=[{"script":"MainWindow.py"}],
options={"py2exe":{
"includes" : ["sip", dcm, svm_path,
'sklearn',
'scipy.sparse.csgraph._validation',
'sklearn.linear_model.sgd_fast.weight_vector']}})
Actually, I have solved the problem in this question scipy with py2exe problesm and solved it using the second answer in that question (the answer), adding the "scipy.sparse.csgraph._validation" in my includes options for the py2exe.
Then I want to do the similar thing for the error "No module named weight_vector", say, adding the "sklearn.linear_model.sgd_fast.weight_vector" in my includes options. However, it didn't work.
I check the directory "sklearn.linear_model.sgd_fast" only to find that the sgd_fast is a ".pyd" file rather than a .py file. Maybe this is why my methods cannot work.
I didn't get any idea about dealing with the pyd file. Have anybody met the similar problems or got any ideas? I really need your help.

Py2Exe Error: Win32com.client causes errors when trying to run created executable

My script that I'm trying to create into an executable contains the following imports:
import csv, time, BeautifulSoup, sys, mechanize, os, traceback, win32com.client as win32
My setup.py looks like this:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
console = [{'script': "tool.py"}],
zipfile = None,
)
The .exe of my program is created successfully, however when I try to run it I receive the following errors:
Traceback (most recent call last):
File "tool.py", line 1, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "win32com\__init__.pyc", line 5, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32api.pyd
Surprisingly, it compiles into an .exe fine if I use bundle_files: = 3 however I need this program to be in one executable, not multiple files. I've read this from the py2exe website but I'm not sure if that's what I need to do/use. If that is the answer I'm looking for, I don't know how to use that or what to do with it. Please explain.
Any help is greatly appreciated!
This was solved by upgrading to Python 2.7. I originally had Python 2.6 installed but the update solved this issue.

No module named _core when using mailer.py on Windows/Python 2.7

I'm trying to configure and run SVN post-commit hook sending mails. I've downloaded class mailer.py, installed Python 2.7 and svn-win32 bindings for svn. The machine is Windows-7 64 bit, the Python is 32 bit. Now the mailer.py ends with error, which is caused by import problem.
When I in python console type "import svn.core" I have following error:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\tools\Python27\lib\site-packages\svn\core.py", line 19, in <module>
from libsvn.core import *
File "c:\tools\Python27\lib\site-packages\libsvn\core.py", line 5, in <module>
import _core
ImportError: No module named _core
while in directory site-packages/libsvn are files such as: _core.dll
I've installed other bindings, pysvn, that was installed correctly, but as far as I've noticed, it's the totally other API so I can't use that for python.py
Does someone had similar problem and knows how to deal with it?
The Python bindings need to load the native Subversion libraries (DLL's). If your Python is 32-bit then you would need 32-bit versions of the native Subversion libraries on PATH.
I have problem like this. Trouble was that python just can not import this library (svn.core and other).
I just make:
import sys
sys.path.append("C:\csvn\lib\svn-python").
My file core.pyc was in C:\csvn\lib\svn-python\svn. Hope it helps somebody. Such behacior for me is strange because there is no "init.py" or "init.pyc" file in svn-python directory. But it works.

Categories