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.
Related
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.
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...
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!
I am testing some models between other things in my python 2.7.6 interpreter cia bpython package installed with pip.
In addition I am using a virtualenv created previously.
When I try type a doblequoes ("") or even slash ("/") character, I get the following message:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 1: ordinal not in range(128)
>>> coll=sess.collections.create("")
Traceback (most recent call last):
File "/home/bgarcial/.virtualenvs/iRODS/bin/bpython", line 11, in <module>
sys.exit(main())
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsies.py", line 79, in main
interactive=(not exec_args))
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsies.py", line 177, in mainloop
process_event(e)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsies.py", line 135, in process_event
repl.process_event(e)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 488, in process_event
return self.process_key_event(e)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 629, in process_key_event
self.add_normal_character(e)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 848, in add_normal_character
self.cursor_offset += 1
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 1345, in _set_cursor_offset
self.update_completion()
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/curtsiesfrontend/repl.py", line 878, in update_completion
self.list_win_visible = BpythonRepl.complete(self, tab)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/repl.py", line 599, in complete
history=self.history)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/autocomplete.py", line 466, in get_completer_bpython
return get_completer(BPYTHON_COMPLETER, cursor_offset, line, **kwargs)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/autocomplete.py", line 446, in get_completer
cursor_offset, line, **kwargs)
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/autocomplete.py", line 174, in matches
for filename in self.safe_glob(os.path.expanduser(text)):
File "/home/bgarcial/.virtualenvs/iRODS/local/lib/python2.7/site-packages/bpython/autocomplete.py", line 161, in safe_glob
return glob.glob(pathname + '*')
File "/usr/lib/python2.7/glob.py", line 27, in glob
return list(iglob(pathname))
File "/usr/lib/python2.7/glob.py", line 60, in iglob
yield os.path.join(dirname, name)
File "/home/bgarcial/.virtualenvs/iRODS/lib/python2.7/posixpath.py", line 78, in join
path += b
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 1: ordinal not in range(128)
(iRODS)➜ ~
In my python interpreter I can see the UTF-8 encoding
(iRODS)➜ ~ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.stdout.encoding
UTF-8
>>>
But, when I use bpython or IPython (installed with pip) , is here when I get the error
(iRODS)➜ ~ bpython
bpython version 0.14.1 on top of Python 2.7.6 /home/bgarcial/.virtualenvs/iRODS/bin/python
>>> import sys
>>> print sys.stdout.encoding
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'FakeOutput' object has no attribute 'encoding'
>>>
In IPython (and IPython 2) works
(iRODS)➜ ~ ipython
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.0 -- An enhanced Interactive Python.
? -> 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.
In [1]: import sys
In [2]: print sys.stdout.encoding
UTF-8
In [3]:
But, the error of encoding denoted previously appear with python, bpython and IPython
I have a problem with some of my interpreter or unless with aome of these utilities associated to it?
As additional information, I am working in my interpreter an API that I installed with pip.
Is possible that there is some problem with these API in relation with Unicode support?
The API is named python-irodsclient (https://github.com/irods/python-irodsclient) and when I ask to developers that create it, they entered an issue in relation with my problem (https://github.com/irods/python-irodsclient/issues/22)
What situation may be happening?
Of anyway I did want share this information here.
Thanks
I used help() in the python3 shell on Ubuntu 14.04
I got this output
Please help , don't know whats wrong.
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/_sitebuiltins.py", line 98, in __call__
import pydoc
File "/usr/lib/python3.4/pydoc.py", line 65, in <module>
import platform
File "/home/omega/platform.py", line 2, in <module>
print("System : ",platform.uname().system)
AttributeError: 'module' object has no attribute 'uname'
>>>
The problem is that platform is the name of a stdlib module, which help uses. By creating a module of your own with the same name that occurs before the stdlib in your sys.path, you're preventing Python from using the standard one.
The fact that your own platform module tries to use the stdlib module of the same name just compounds the problem. That isn't going to work; your import platform inside that module is just importing itself.
The solution is to not collide names like this. Look at the list of the standard modules, and don't create anything with the same name as any of them if you want to use features from that module, directly or indirectly.
In other words: Rename your platform.py to something else, or put it inside a package.
File "/home/omega/platform.py", line 2, in <module>
print("System : ",platform.uname().system)
This is the problem, go to platform.py and fix it, it will be ok. It says, platform has not any method called uname you probably misstyped.