I am getting error while while using "zappa init' - python

I am using python 3.8 and zappa 0.51.0. I have installed zappa in a virtual environment and created AWS account also but when I am trying to command "zappa init" its showing error given below
(.env) D:\rough work\crud>zappa init
Traceback (most recent call last):
File "c:\users\dwipal shrirao\appdata\local\programs\python\python38\Lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\dwipal shrirao\appdata\local\programs\python\python38\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\rough work\crud\.env\Scripts\zappa.exe\__main__.py", line 4, in <module>
File "d:\rough work\crud\.env\lib\site-packages\zappa\cli.py", line 44, in <module>
from .core import Zappa, logger, API_GATEWAY_REGIONS
File "d:\rough work\crud\.env\lib\site-packages\zappa\core.py", line 33, in <module>
import troposphere
File "d:\rough work\crud\.env\lib\site-packages\troposphere\__init__.py", line 586, in <module>
class Template(object):
File "d:\rough work\crud\.env\lib\site-packages\troposphere\__init__.py", line 588, in Template
'AWSTemplateFormatVersion': (basestring, False),
NameError: name 'basestring' is not defined
what is happening and how I can get rid of this error?

The builtin basestring abstract type was removed. Use str instead. The str and bytes types don’t have functionality enough in common to
warrant a shared base class. The 2to3 tool (see below) replaces every
occurrence of basestring with str.
As you are with python version 3.8, use str instead.

Related

TypeError: must provide a stream to wrap

When I type pipenv shell in my command line to activate virtual environment I got this error:
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\asus\AppData\Roaming\Python\Python39\Scripts\pipenv.exe\__main_
_.py", line 4, in <module>
File "C:\Users\asus\AppData\Roaming\Python\Python39\site-packages\pipenv\__ini
t__.py", line 41, in <module>
stdout = get_text_stream("stdout")
File "C:\Users\asus\AppData\Roaming\Python\Python39\site-packages\pipenv\vendo
r\vistir\misc.py", line 1191, in get_text_stream
return get_wrapped_stream(sys_stream, encoding)
File "C:\Users\asus\AppData\Roaming\Python\Python39\site-packages\pipenv\vendo
r\vistir\misc.py", line 969, in get_wrapped_stream
raise TypeError("must provide a stream to wrap")
TypeError: must provide a stream to wrap
if you know how to overcome this error, please answer. Thank you.
I think what your problem is, that you're missing stdout. I've had a similar problem with a script that was invoked from KDE. It kind of failed with a similar error message.
My fix for the moment was to simply redirect the stdout to /dev/null. I assume that this won't quite work, considering you are working from within a shell that should have stdin/stout. You might have to reconsider your working environment. But just a guess.

cProfiler working weirdly with multiprocessing

I got an error for this code:
from pathos.multiprocessing import ProcessingPool
def diePlz(im):
print('Whoopdepoop!')
def caller():
im = 1
pool = ProcessingPool()
pool.map(diePlz,[im,im,im,im])
if __name__=='__main__':
caller()
when I ran it with the cProfiler: (python3 -m cProfile testProfiler.py)
multiprocess.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/rohit/.local/lib/python3.6/site-packages/multiprocess/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/rohit/.local/lib/python3.6/site-packages/multiprocess/pool.py", line 44, in mapstar
return list(map(*args))
File "/home/rohit/.local/lib/python3.6/site-packages/pathos/helpers/mp_helper.py", line 15, in <lambda>
func = lambda args: f(*args)
File "testProfiler.py", line 3, in diePlz
print('Whoopdepoop!')
NameError: name 'print' is not defined
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/cProfile.py", line 160, in <module>
main()
File "/usr/lib/python3.6/cProfile.py", line 153, in main
runctx(code, globs, None, options.outfile, options.sort)
File "/usr/lib/python3.6/cProfile.py", line 20, in runctx
filename, sort)
File "/usr/lib/python3.6/profile.py", line 64, in runctx
prof.runctx(statement, globals, locals)
File "/usr/lib/python3.6/cProfile.py", line 100, in runctx
exec(cmd, globals, locals)
File "testProfiler.py", line 11, in <module>
caller()
File "testProfiler.py", line 8, in caller
pool.map(diePlz,[im,im,im,im])
File "/home/rohit/.local/lib/python3.6/site-packages/pathos/multiprocessing.py", line 137, in map
return _pool.map(star(f), zip(*args)) # chunksize
File "/home/rohit/.local/lib/python3.6/site-packages/multiprocess/pool.py", line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/home/rohit/.local/lib/python3.6/site-packages/multiprocess/pool.py", line 644, in get
raise self._value
NameError: name 'print' is not defined
But when I ran it without the cProfiler:
$ python3 testProfiler.py
Whoopdepoop!
Whoopdepoop!
Whoopdepoop!
Whoopdepoop!
The code that I've provided is a minimal working example for the problem. There is a much larger code that I want to debug, but am not able to do so because cProfiler keeps raising weird errors.
In this case, the point of importance is
NameError: name 'print' is not defined
which means python3 is not able to recognize print itself. In my code, it was not able to recognize range.
So, I realize this is a long time after the original post, but I have this exact same issue.
In my case I was getting the exact same error as the original post - python builtin functions such as print() or len() resulted in errors like this:
NameError: name 'len' is not defined
I'm currently running multiprocess version 0.70.11.1 and dill version 0.3.3 (components of pathos that make process based parallelism work).
Based on what I found in an issue comment: https://github.com/uqfoundation/pathos/issues/129#issuecomment-536081859 one of the package authors recommends trying:
import dill
dill.settings['recurse'] = True
At least in my case, the above fixed the error!

Python Web Scraping (edX)

I am trying to download a course on edx. Please refer to the following readme (https://github.com/coursera-dl/edx-dl/blob/master/README.md). I installed Anaconda for Windows (I am running Windows 10 in Parallel Desktop).
In the last step, I typed in the following command: C:\edx-dl-master\edx-dl-master>edx-dl -u user#user.com COURSE-URL and upon entering my edX password, get the following:
Building initial headers for future requests.
Getting initial CSRF token.
Found CSRF token.
Logging into Open edX site: https://courses.edx.org/login_ajax
Extracting course information from dashboard.
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in
_run_module_as_main
"__main__", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\edx-dl.exe\__main__.py", line 9, in <module>
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\edx_dl.py", line 1011, in main
for selected_course in selected_courses}
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\edx_dl.py", line 1011, in <dictcomp>
for selected_course in selected_courses}
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\edx_dl.py", line 186, in get_available_sections
sections = page_extractor.extract_sections_from_html(page, BASE_URL)
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\parsing.py", line 403, in extract_sections_from_html
for i, section_soup in enumerate(sections_soup, 1)]
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\parsing.py", line 403, in <listcomp>
for i, section_soup in enumerate(sections_soup, 1)]
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\parsing.py", line 392, in _make_subsections
for i, s in enumerate(subsections_soup, 1)]
File "c:\programdata\anaconda3\lib\site-packages\edx_dl\parsing.py", line 392, in <listcomp>
for i, s in enumerate(subsections_soup, 1)]
AttributeError: 'NoneType' object has no attribute 'string'
I am new to Python, and am not sure what remedial measures I can take.
Try
git clone https://github.com/coursera-dl/edx-dl/blob/master/README.md
Install git first.

Syntax error in a Python library, and I'm not sure how to proceed

I'm using pyramid 1.5.1 and python 3.2, and I just added quite a bit of code and a couple libraries to my project.
On running development.ini, I'm getting the error below.
If I had to take a wild guess, I would say that this particular library (looks like Markupsafe?) isn't compatible with Python3...but the project page seems to indicate that it is. Problem is, I'm not calling this library directly, it's being used by another library that would be very difficult to replace.
I'm new to Python programming, and I was wondering what my options are here Or what the best way to debug is?
(finance-env)user1#finance1:/var/www/finance/corefinance/corefinance$ /var/www/finance/finance-env/bin/pserve /var/www/finance/corefinance/development.ini --reload
Starting subprocess with file monitor
Traceback (most recent call last):
File "/var/www/finance/finance-env/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.5.1', 'console_scripts', 'pserve')()
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/scripts/pserve.py", line 316, in run
global_conf=vars)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/scripts/pserve.py", line 340, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/var/www/finance/finance-env/lib/python3.2/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/var/www/finance/corefinance/corefinance/__init__.py", line 35, in main
session_factory=session_factory
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/config/__init__.py", line 301, in __init__
exceptionresponse_view=exceptionresponse_view,
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/config/__init__.py", line 412, in setup_registry
self.include(inc)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/config/__init__.py", line 755, in include
c(configurator)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid_debugtoolbar-2.1-py3.2.egg/pyramid_debugtoolbar/__init__.py", line 113, in includeme
config.include('pyramid_mako')
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/config/__init__.py", line 727, in include
c = self.maybe_dotted(callable)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/config/__init__.py", line 825, in maybe_dotted
return self.name_resolver.maybe_resolve(dotted)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/path.py", line 320, in maybe_resolve
return self._resolve(dotted, package)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/path.py", line 327, in _resolve
return self._zope_dottedname_style(dotted, package)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid/path.py", line 370, in _zope_dottedname_style
found = __import__(used)
File "/var/www/finance/finance-env/lib/python3.2/site-packages/pyramid_mako-1.0.2-py3.2.egg/pyramid_mako/__init__.py", line 18, in <module>
from mako.lookup import TemplateLookup
File "/var/www/finance/finance-env/lib/python3.2/site-packages/Mako-1.0.0-py3.2.egg/mako/lookup.py", line 9, in <module>
from mako.template import Template
File "/var/www/finance/finance-env/lib/python3.2/site-packages/Mako-1.0.0-py3.2.egg/mako/template.py", line 10, in <module>
from mako.lexer import Lexer
File "/var/www/finance/finance-env/lib/python3.2/site-packages/Mako-1.0.0-py3.2.egg/mako/lexer.py", line 11, in <module>
from mako import parsetree, exceptions, compat
File "/var/www/finance/finance-env/lib/python3.2/site-packages/Mako-1.0.0-py3.2.egg/mako/parsetree.py", line 9, in <module>
from mako import exceptions, ast, util, filters, compat
File "/var/www/finance/finance-env/lib/python3.2/site-packages/Mako-1.0.0-py3.2.egg/mako/filters.py", line 38, in <module>
import markupsafe
File "/var/www/finance/finance-env/lib/python3.2/site-packages/MarkupSafe-0.23-py3.2-linux-x86_64.egg/markupsafe/__init__.py", line 70
def __new__(cls, base=u'', encoding=None, errors='strict'):
^
SyntaxError: invalid syntax
The MarkupSafe package uses syntax only supported by Python 3.3 and up. Python 3.2 is not supported anymore as of version 0.16.
The u'unicode' literal syntax was introduced in PEP 414 to make it easier to create library code that can support both Python 2 and 3.
Either upgrade to Python 3.3 (or 3.4 even), or downgrade MarkupSafe to 0.15, the last version to support Python 3.2.
I do see that Mako removes the MarkupSafe dependency when you are using Python 3.2; if nothing else depends on it is perhaps safe to remove the package altogether. The mako.filter source code certainly will fall back to a local implementation if the package is not installed.

Lamson (Python SMTP Server) Error

I've installed Lamson via easy_install on my webfaction shared hosting. Went to do the '30 Second Introduction' (See http://lamsonproject.org/docs/getting_started.html) but after:
[almacmillan#web129 python2.6]$ lamson gen -project mymailserver
I get:
Traceback (most recent call last):
File "/home/almacmillan/bin/lamson", line 5, in <module>
pkg_resources.run_script('lamson==1.0', 'lamson')
File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 448, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 1166, in run_script
execfile(script_filename, namespace, namespace)
File "/home/almacmillan/lib/python2.6/lamson-1.0-py2.6.egg/EGG-INFO/scripts/lamson", line 3, in <module>
from lamson import args, commands
File "/home/almacmillan/lib/python2.6/lamson-1.0-py2.6.egg/lamson/commands.py", line 28, in <module>
from lamson import server, args, utils, mail, routing, queue, encoding
File "/home/almacmillan/lib/python2.6/lamson-1.0-py2.6.egg/lamson/utils.py", line 12, in <module>
from daemon import pidlockfile
File "/home/almacmillan/lib/python2.6/python_daemon-1.5.5-py2.6.egg/daemon/pidlockfile.py", line 33, in <module>
class PIDLockFile(LinkFileLock, object):
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
I'm a very new programmer. I'd really appreciate some debugging help.
There's already a ticket for the problem here: http://support.lamsonproject.org/tktview?name=06d488141d
Use http://pypi.python.org/pypi/lockfile/0.8 as 0.9.1's
API changes break python_daemon-1.5.5-py2.5.egg/daemon/pidlockfile.py.
0.9.1 comes with easy_install. So, it's not an issue with lamson.
To solve: remove lockfile 0.9.1 from your Python site-packages
and get 0.8 from the cheese shop instead.

Categories