Everything is obvious as the below image and the codes followed it :
I want to import a module that phycially there is in the D:\pyusb-1.0.0a2\usb, but I receive errors!
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> sys.path.append('d:\pyusb-1.0.0a2\usb')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape
>>> sys.path.append('d:/pyusb-1.0.0a2/usb')
>>> from usb import core
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from usb import core
ImportError: No module named 'usb'
>>> import core
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import core
File "d:/pyusb-1.0.0a2/usb\core.py", line 44, in <module>
import usb.util as util
ImportError: No module named 'usb'
>>> import usb.core
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import usb.core
ImportError: No module named 'usb'
>>>
You need to append d:/pyusb-1.0.0a2/ to your Python path, and not d:/pyusb-1.0.0a2/usb/.
As you can see when trying to import core the error is no longer that your import failed, but that the usb.core module did not manage to import usb.util since there's no usb module available in your Python path, only modules inside usb, such as core or util.
Related
When I try to import Marionette driver in Python, I get this response:
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from marionette import Marionette
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/marionette_client-2.0.0-py2.7.egg/marionette/__init__.py", line 7, in <module>
from .marionette_test import (
File "/usr/local/lib/python2.7/dist-packages/marionette_client-2.0.0-py2.7.egg/marionette/marionette_test.py", line 18, in <module>
from marionette_driver.errors import (
File "/usr/local/lib/python2.7/dist-packages/marionette_driver-1.1.1-py2.7.egg/marionette_driver/__init__.py", line 7, in <module>
from marionette_driver import (
File "/usr/local/lib/python2.7/dist-packages/marionette_driver-1.1.1-py2.7.egg/marionette_driver/expected.py", line 8, in <module>
from marionette import HTMLElement
File "/usr/local/lib/python2.7/dist-packages/marionette_driver-1.1.1-py2.7.egg/marionette_driver/marionette.py", line 20, in <module>
from mozrunner import B2GEmulatorRunner
ImportError: cannot import name B2GEmulatorRunner
>>>
I have the Mozrunner package installed, but it does not have any B2GEmulatorRunner. Any suggestion as to what is causing this issue and how I can resolve this?
Edit:
After updating my entire Python 2.7 library with PIP, now I am stuck with this issue:
>>> import marionette
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/marionette/__init__.py", line 7, in <module>
from .marionette_test import (
ImportError: No module named marionette_test
I'm trying to install Flask inside Wine so that I can package with cx_freeze. I've had it working for a while, but I've just added Flask to the project.
However, I can't seem to import Flask due to a missing library required by the core asyncio library. The cause of this is an import that is only included in windows systems called _overlapped. The code can be seen here.
I can confirm that there is a library contained within the dlls folder:
root#375a857194f3:/src# find /root/.wine -iname *overlapped*
/root/.wine/drive_c/Python36/DLLs/_overlapped.pyd
An example import and error message can be found below.
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
Traceback (most recent call last):
File "C:\Python36\lib\asyncio\__init__.py", line 16, in <module>
from . import _overlapped
ImportError: cannot import name '_overlapped'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\asyncio\__init__.py", line 18, in <module>
import _overlapped # Will also be exported.
OSError: [WinError 10045] Windows Error 0x273d
When I run a code which imports spynner, I get the following error:
> python .\spynner-test.py
Traceback (most recent call last):
File ".\spynner-test.py", line 10, in <module>
import spynner
File "C:\Anaconda\lib\site-packages\spynner\__init__.py", line 2, in <module>
from browser import *
File "C:\Anaconda\lib\site-packages\spynner\browser.py", line 56, in <module>
from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
ImportError: DLL load failed: The specified procedure could not be found.
A funny thing is that I can import those things in normal python shell without any problem:
> python
Python 2.7.5 |Anaconda 1.9.2 (64-bit)| (default, Jul 1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
>>>
But after import spynner fails,
> python
Python 2.7.5 |Anaconda 1.9.2 (64-bit)| (default, Jul 1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import spynner
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\spynner\__init__.py", line 2, in <module>
from browser import *
File "C:\Anaconda\lib\site-packages\spynner\browser.py", line 56, in <module>
from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
ImportError: DLL load failed: The specified procedure could not be found.
>>> from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
>>>
Okay I figured it out. The problem is that spynner first tries to import PySide, and it gets an error in importing QSslConfiguration from PyQt4.QtNetwork. And then it switches to PyQt4, and apparently the previously imported PySide makes the PyQt4 import fail. When I remove the try: part in browser.py I could import spynner fine.
Python's standard logging module is supposed to contain a useful captureWarnings function that allows integration between the logging and the warnings modules. However, it seems that my installation misses this function:
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'captureWarnings'
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>> import warnings
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>>
What am I doing wrong?
Unfortunately, there is no such method in Python 2.6.5's logging module. You need Python 2.7.
I can't import ctypes on the production GAE server, which is causing our code to break. Seemingly, urllib and urllib2 also rely on this library, but somehow it's possible to import them on production through the console (e.g. navigate to www.myapp.com/console). Is this a feature or a bug? Thanks!
Python 2.5.2 (r252:60911, Mar 17 2011, 15:16:30)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(Google App Engine/1.5.1)
>>> from lib import cloud
Traceback (most recent call last):
File "/base/data/home/apps/s~getprofound1/1-01.351465921648985319/console/app/models/console.py", line 170, in processSource
exec bytecode in statement_module.__dict__
File "<string>", line 1, in <module>
File "/base/data/home/apps/s~getprofound1/1-01.351465921648985319/lib/cloud/__init__.py", line 102, in <module>
from . import cloudconfig as cc
File "/base/data/home/apps/s~getprofound1/1-01.351465921648985319/lib/cloud/cloudconfig.py", line 50, in <module>
from .util import configmanager
File "/base/data/home/apps/s~getprofound1/1-01.351465921648985319/lib/cloud/util/__init__.py", line 25, in <module>
import ctypes
File "/base/python_runtime/python_dist/lib/python2.5/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes
ctypes is not available in the Python 2.5 runtime or in the current Python 2.7 runtime. See the knowledge base for more details and this list enumerating white-listed module.