How to resolve 'ImportError: No module named marionette_test' - python

In my Python script I am trying to set some phone settings through Marionette driver. I am importing the following:
from marionette_driver import By
from marionette_driver import Wait
from marionette import Marionette
Then I am attempting to open a client session with the device:
client = Marionette('localhost', port=2828)
client.start_session()
However, I am receiving UnknownCommandException:
Traceback (most recent call last):
File "xyz.py", line 30, in <module>
client.start_session()
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/decorators.py", line 26, in _
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 1243, in start_session
body)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/decorators.py", line 26, in _
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 741, in _send_message
self._handle_error(err)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 765, in _handle_error
raise errors.lookup(error)(message, stacktrace=stacktrace)
marionette_driver.errors.UnknownCommandException: WebDriver:NewSession
FYI, I am using marionette-driver 1.1.1
Any suggestion regarding resolving this issue will be much appreciated.
Edit on 10/26/2018
It is returning a different error message now:
$ python
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 "./xyz.py", line 7, in <module>
from marionette import Marionette
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

This is probably due to an outdated driver as answered here: WebDriver Error New Session
You can download the lastest from the Github Mozilla Repo.
If it is not Repo relate then it could be because .pyc files linger and python tries to use them first before recompiling.
Basically you would find the relate .pyc files and remove then so the source is recompiled. Check this open bug for more info.
Thank you. Good day.

Related

Trace files/modules loaded when launching python

I am using Paraview 4.0.1 under Ubuntu 14.04 LTS.
But I guess the answer to this question does not necessarily requires knowledge specific to Paraview python.
When I load a python prompt at the command line everything "works well":
$ pvpython
Python 2.7.6 (default, Oct 26 2016, 20:33:43)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
paraview version 4.0.1
>>>
But when I load the python shell within the GUI, from paraview.simple import * fails, either when automatically (at startup) or explicitly imported:
Python 2.7.6 (default, Oct 26 2016, 20:33:43)
[GCC 4.8.4] on linux2
from paraview.simple import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/paraview/simple.py", line 41, in <module>
import servermanager
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 3157, in <module>
__initialize()
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 3148, in __initialize
c = Connection(iter.GetCurrentSessionId(), iter.GetCurrentSession())
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 1935, in __init__
_createModules(self.Modules)
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2567, in _createModules
m.filters = createModule('filters')
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2629, in createModule
if (prop.GetInformationOnly() and propName != "TimestepValues" ) \
AttributeError: 'NoneType' object has no attribute 'GetInformationOnly'
>>> from paraview.simple import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2190, in find_module
if vtkPVPythonModule.HasModule(fullname):
AttributeError: 'NoneType' object has no attribute 'HasModule'
>>>
How can I trace the different sequence of steps taken by each mode of loading a python shell, so as to identify the source of error?
In addition to this manifestation, I found two other differences:
In the command prompt, from paraview.simple import * is not executed automatically, while in the GUI it is. Where is this set?
In the command prompt, having set PYTHONSTARTUP=${HOME}/.pythonrc, which sets import readline, rlcompleter (actually, within a try-except construct), allows for tab completion.
In the GUI, .pythonrc is not read. Why is this? How can I tell the filename which would be read upon startup if it exists?
I have found one option which gives some information, I do not know if it is the only/best one.
Setting
$ export PYTHONVERBOSE=2
(or a different integer for verbosity level [1]) gives a lot of info.
Still, I couldn't find the source of error...

Cannot import logging.py after I renamed one of my source files logging.py in my Eclipse project

I thought, I broke Eclipse by renaming one of my source file logging.py, I quickly changed the name to something else but Eclipse cannot find the original python standard file ... I reinstalled my Anaconda install but it did not correct the problem ... and I later discovered it was likely a Python problem (see Edit 1)
When I ask Eclipse to find or open the file from the 'import logging' line, it seems it cannot find it ...
Any idea to correct this problem without reinstalling Eclipse?
Traceback (most recent call last):
File "C:\Users\ailete\workspace\landema\main.py", line 56, in <module>
import requests
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\__init__.py", line 27, in <module>
from . import urllib3
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\urllib3\connectionpool.py", line 35, in <module>
from .connection import (
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\urllib3\connection.py", line 43, in <module>
from .util.ssl_ import (
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\urllib3\util\__init__.py", line 19, in <module>
from .retry import Retry
File "C:\Users\ailete\Anaconda2\Lib\site-packages\requests\packages\urllib3\util\retry.py", line 15, in <module>
log = logging.getLogger(__name__)
AttributeError: 'module' object has no attribute 'getLogger'
Edit 1
The problem happens with the executable generated by pyinstaller too ?! :
...
LOADER: Running main.py
Traceback (most recent call last):
File "<string>", line 43, in <module>
File "c:\users\ailete\appdata\local\temp\pip-build-iulqaq\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 363, in load_module
File "C:\Users\ailete\workspace\landema\entities.py", line 7, in <module>
from config import locale, ribbon_menu
File "c:\users\ailete\appdata\local\temp\pip-build-iulqaq\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 363, in load_module
File "C:\Users\ailete\workspace\landema\config.py", line 7, in <module>
import logging
ImportError: No module named logging
main returned -1
...
First, define modules path, where built-in module logging is placed:
user#host:$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['/usr/lib/python2.7', ... ]
Second, ensure that there is a logging package. In my OS i have /usr/lib/python2.7/logging. I think you renamed the package accidentally; If so, rename it back.
I came across a very similar problem. The error I was receiving was: "AttributeError: ‘flask.logging’ object has no attribute ‘getLogger’". And the solution was downgrade the package Flask (settings -> project -> project interpreter).
Sorry, I solved it myself.
I thought Eclipse delete the .pyc files when I told it to clean the project, but it is not how it works apparently, So after 2 reinstalls of anaconda and configuration tweaks for this project (I have others ...), I finally remembered to check that ... the .pyc for the file was still there with the old name 'logging.pyc' ... thanks Eclipse as always, for wasting my time with your quirks!

EOF Error when importing python package

I am working on a project which utilizes the wbdata package for python, which is a wrapper for the world bank api. It was working fine until I made what I have guessed to be to large of a request of data, which I had to cancel, and now the package won't even load when I use the import wbdata function. Here's what I get
Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC
v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
%guiref -> A brief reference about the graphical user interface.
In [1]: import wbdata as wb
Traceback (most recent call last):
File "<ipython-input-1-ae1872a5f07c>", line 1, in <module>
import wbdata as wb
File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\__init__.py", line 23, in <module>
from .api import (get_country, get_data, get_dataframe, get_panel,
File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\api.py", line 31, in <module>
from . import fetcher
File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\fetcher.py", line 104, in <module>
if not len(CACHE.cache)== 0:
File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\fetcher.py", line 82, in cache
cache = pickle.load(cachefile)
EOFError
In [2]:
Could someone please help me out with getting this package working again?
Thanks
Josh
EDIT- Ok after running the %debug cachefile.name I get the following;
%debug cachefile.name
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
> c:\users\josh new\anaconda\lib\encodings\cp1252.py(15)decode()
14 def decode(self,input,errors='strict'):
---> 15 return codecs.charmap_decode(input,errors,decoding_table)
16
ipdb> c
Traceback (most recent call last):
File "C:\Users\Josh New\Anaconda\lib\site-packages\IPython\core\magics\execution.py", line 817, in _run_with_debugger
deb.run(code, code_ns)
File "C:\Users\Josh New\Anaconda\lib\bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
NameError: name 'cachefile' is not defined
Use ipython's magic %debug and check what cachefile's file name is. If it's a regular file, name should be accessible as cachefile.name.
Then nuke that file.
I think I have fixed it by going the wbdata folder in Appdata\Local\wbdata and deleting the cache file that was in it. seems to work now.

When I try and run pyspark.cmd I get the error message "find: 'version': No such file or directory"

I'm trying to get started with Apache Spark. I'd like to use it via python. However, when I run pyspark from the command line I get the following error message:
C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin>pyspark.cmd
Running python with PYTHONPATH=C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.
4\bin\..\python\lib\py4j-0.8.2.1-src.zip;C:\Programs\Apache\Spark\spark-1.2.0-bi
n-hadoop2.4\bin\..\python;
Python 2.7.8 |Anaconda 2.1.0 (32-bit)| (default, Jul 2 2014, 15:13:35) [MSC v.1
500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
find: 'version': No such file or directory
else was unexpected at this time.
Traceback (most recent call last):
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin\..\python\pyspark
\shell.py", line 45, in <module>
sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 102, in __init__
SparkContext._ensure_initialized(self, gateway=gateway)
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 211, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway()
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\java_g
ateway.py", line 73, in launch_gateway
raise Exception(error_msg)
Exception: Launching GatewayServer failed with exit code 255!
Warning: Expected GatewayServer to output a port, but found no output.
When I try and run the scala interface by running spark-shell I get the message:
find: 'version': No such file or directory
else was unexpected at this time.
I cant find any info on this error online, other than
which turned out to be a dead end.
https://issues.apache.org/jira/browse/SPARK-3808
Please help!
I had the same problem in spark 1.2.0 but not in spark 1.0.2.
The reason was in my case that I had cygwin in the DOS classpath.
Spark uses the find command in the file 'spark-class2.cmd', which used then the cygwin find command instead of the DOS find command, which works somewhat different.
I removed cygwin from the DOS PATH, which solved the problem.
Regards, Felix

Python 2.5 interpreter is throwing a PyNoAppError when I run >>>> help('modules')

My Python interpreter is giving me an ugly error when I try to pull up a list of all the accessible modules (see below). I've googled "wx._core.PyNoAppError: The wx.App object must be created first!" and I haven't found a good explanation of how to fix it in this context. Can anyone help me out?
Python 2.5.4 (r254:67916, Aug 1 2011, 15:52:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py:110: DeprecationWarning: twisted.flow is unmaintained.
__import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/words/im/__init__.py:8: UserWarning: twisted.im will be undergoing a rewrite at some point in the future.
warnings.warn("twisted.im will be undergoing a rewrite at some point in the future.")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.py", line 348, in __call__
return pydoc.help(*args, **kwds)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1645, in __call__
self.help(request)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1682, in help
elif request == 'modules': self.listmodules()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1803, in listmodules
ModuleScanner().run(callback)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1854, in run
for importer, modname, ispkg in pkgutil.walk_packages():
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py", line 110, in walk_packages
__import__(name)
File "/var/tmp/wxWidgets/wxWidgets-13~231/2.5/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wxaddons/__init__.py", line 29, in <module>
File "/var/tmp/wxWidgets/wxWidgets-13~231/2.5/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-unicode/wx/_misc.py", line 3298, in __init__
wx._core.PyNoAppError: The wx.App object must be created first!
if you call help('modules') then, as defined in your site.py, pydoc.help() is called.
This results in a call to Helper.listmodules() which then calls the ModuleScanner() which is 'An interruptible scanner that searches module synopses' as per its docstring.
Unfortunately not all modules/packages are capable of being scanned, as that includes importing the module. You are however lucky that you just get an error. On my system (Linux, Python 2.7.3) this gives a segmentation fault

Categories