Import pythoncom error - python

I am using python version 3.6.1 and my operating system is Windows 10
My code is not working and I am getting the following error:
Traceback (most recent call last): File "<pyshell#2>", line 1, in
<module>
import pythoncom File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pythoncom.py",
line 2, in <module>
import pywintypes File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py",
line 127, in <module>
__import_pywin32_system_module__("pywintypes", globals()) File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py",
line 114, in __import_pywin32_system_module__
mod = imp.load_dynamic(modname, found) File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\imp.py",
line 342, in load_dynamic
return _load(spec)
TypeError: bad argument type for built-in operation
Please help me to Complete my first script.

Related

delphi app with python4delphi , fails at UNIX computer with -> EPyValueError with Message

I run an Delphi application using Python4Delphi under WINDOWS and LINUX.
Execution on WINDOWS works as expected
Execution on LINUX returned the following error message
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 2349, in <module>
switch_backend(rcParams["backend"])
File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 221, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module>
from . import _backend_tk
File "/usr/lib/python3/dist-packages/matplotlib/backends/_backend_tk.py", line 6, in <module>
import tkinter as tk
File "/usr/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+68002f is not in range [U+0000; U+10ffff
the code uses numpy and mathplotlib, both packages are installed
I installed tkinter on my LINUX computing system

Python Eclipse PyDev

I am a complete newbie to Python.
I have downloaded and installed Anaconda 3.5.2 on Windows 7, then Eclipse Photon. Installed the PyDev Plugin.
I was able to run a few simple test programs in Eclipse.
Suddenly, without installing anything I get
Error processing line 1 of C:\Anaconda3\lib\site-packages\matplotlib-2.2.2-py3.6-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "C:\Anaconda3\lib\types.py", line 171, in <module>
import functools as _functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 541, in <module>
main()
File "C:\Anaconda3\lib\site.py", line 523, in main
known_paths = addsitepackages(known_paths)
File "C:\Anaconda3\lib\site.py", line 320, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Anaconda3\lib\site.py", line 178, in addpackage
import traceback
File "C:\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Anaconda3\lib\linecache.py", line 8, in <module>
import functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
even with a "Hello World" which ran before
Any ideas what could cause this?
I have found the reason:
I have added a "PyDev Package" named "collections" in the IDE. This collided with something ....
You can try a few things. Have you tried updating the package in conda? It is possible it is not up to date. Also, with Eclipse (and with most IDEs) if things that were working a moment break without any changes it is a sign you should quit the program, give it a moment to settle, and try reopening and rerunning your code. Sometimes it is the tool's fault!

ABI incompatibility while importing `scipy.sparse`

I'm running a script in a virtual environment on a new machine. Running the script gives me the following traceback.
Traceback:
Traceback (most recent call last):
File "zoneMapRGB.py", line 11, in <module>
from skimage import io, color
File "/opt/python/3.6/lib/python3.6/site-packages/skimage/io/__init__.py", line 11, in <module>
from ._io import *
File "/opt/python/3.6/lib/python3.6/site-packages/skimage/io/_io.py", line 7, in <module>
from ..color import rgb2grey
File "/opt/python/3.6/lib/python3.6/site-packages/skimage/color/__init__.py", line 1, in <module>
from .colorconv import (convert_colorspace,
File "/opt/python/3.6/lib/python3.6/site-packages/skimage/color/colorconv.py", line 368, in <module>
rgb_from_xyz = linalg.inv(xyz_from_rgb)
File "/opt/python/3.6/lib/python3.6/site-packages/scipy/linalg/basic.py", line 947, in inv
a1 = _asarray_validated(a, check_finite=check_finite)
File "/opt/python/3.6/lib/python3.6/site-packages/scipy/_lib/_util.py", line 228, in _asarray_validated
import scipy.sparse
File "/opt/python/3.6/lib/python3.6/site-packages/scipy/sparse/__init__.py", line 229, in <module>
from .csr import *
File "/opt/python/3.6/lib/python3.6/site-packages/scipy/sparse/csr.py", line 15, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: /opt/matlab/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../sys/os/glnxa64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /opt/python/3.6/lib/python3.6/site-packages/scipy/sparse/_sparsetools.cpython-36m-x86_64-linux-gnu.so)
It seems scipy is trying to get libstdc++.so.6 from a matlab folder instead of the python directory. Is there any way to correct this behavior?

Anaconda error while opening prompt

Whenever I open Anaconda prompt, I get this
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\souvi\Anaconda3\lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 is not a valid Win32 application.
Traceback (most recent call last):
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\cli\main.py", line 170, in main
import conda.cli.activate as activate
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\cli\activate.py", line 10, in <module>
from ..exceptions import (ArgumentError, CondaEnvironmentError, CondaSystemExit, CondaValueError,
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\exceptions.py", line 16, in <module>
from .common.url import maybe_unquote
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\common\url.py", line 8, in <module>
import socket
File "C:\Users\souvi\Anaconda3\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\souvi\Anaconda3\Scripts\conda-script.py", line 5, in <module>
sys.exit(conda.cli.main())
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\cli\main.py", line 177, in main
from ..exceptions import handle_exception
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\exceptions.py", line 16, in <module>
from .common.url import maybe_unquote
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\common\url.py", line 8, in <module>
import socket
File "C:\Users\souvi\Anaconda3\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
It worked perfectly fine till a few days ago.
Also on cmd, when I type in the conda command, it displays:
C:\Users\souvi>conda
Traceback (most recent call last):
File "C:\Users\souvi\Anaconda3\Scripts\conda-script.py", line 5, in <module>
sys.exit(conda.cli.main())
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\cli\main.py", line 181, in main
from ..exceptions import conda_exception_handler
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\exceptions.py", line 16, in <module>
from .common.url import maybe_unquote
File "C:\Users\souvi\Anaconda3\lib\site-packages\conda\common\url.py", line 8, in <module>
import socket
File "C:\Users\souvi\Anaconda3\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
How do I fix this?

import module failed

The version I used is python2.7, error occurs when I used script, but it works in command line.
from twisted.internet import protocol, reactor
and the errors:
ravjqpejcnngpig.eqo/re/fgh/ocr
Traceback (most recent call last):
File "./tsTclntTW.py", line 5, in <module>
from twisted.internet import protocol, reactor
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 18, in <module>
from zope.interface import Interface
File "/usr/local/lib/python2.7/dist-packages/zope.interface-4.0.1-py2.7-linux-x86_64.egg/zope/__init__.py", line 3, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 698, in <module>
self.callbacks.append(callback)
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 701, in Environment
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 96, in get_supported_platform
distutils.util.get_platform() normally reports the minimum version
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 222, in get_build_platform
# fallback for MacPorts
File "/usr/lib/python2.7/distutils/util.py", line 65, in get_platform
osname = string.lower(osname)
AttributeError: 'module' object has no attribute 'lower'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
import problem_report
File "/usr/lib/python2.7/dist-packages/problem_report.py", line 16, in <module>
from email.mime.multipart import MIMEMultipart
File "/usr/lib/python2.7/email/mime/multipart.py", line 9, in <module>
from email.mime.base import MIMEBase
File "/usr/lib/python2.7/email/mime/base.py", line 9, in <module>
from email import message
File "/usr/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/usr/lib/python2.7/email/charset.py", line 14, in <module>
import email.quoprimime
File "/usr/lib/python2.7/email/quoprimime.py", line 48, in <module>
from string import hexdigits
ImportError: cannot import name hexdigits
Original exception was:
Traceback (most recent call last):
File "./tsTclntTW.py", line 5, in <module>
from twisted.internet import protocol, reactor
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 18, in <module>
from zope.interface import Interface
File "/usr/local/lib/python2.7/dist-packages/zope.interface-4.0.1-py2.7-linux-x86_64.egg/zope/__init__.py", line 3, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 698, in <module>
self.callbacks.append(callback)
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 701, in Environment
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 96, in get_supported_platform
distutils.util.get_platform() normally reports the minimum version
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 222, in get_build_platform
# fallback for MacPorts
File "/usr/lib/python2.7/distutils/util.py", line 65, in get_platform
osname = string.lower(osname)
AttributeError: 'module' object has no attribute 'lower'
I have re-installed the Python I used and it doesn't work, I'm in Ubuntu 12.04. Also I have do
grep ravjqpejcnngpig.eqo/re/fgh/ocr . -R -n
under /usr/lib/python2.7 but nothing returned.
Perhaps you have a module named string in your project, and it shadows the library module of the same name.
EDIT: To find out, add this to your script just before the failing import statement:
import string
print string.__file__

Categories