Flask attribute error - python

I can't import Flask 1.0 or run the development server all of a sudden.
Traceback (most recent call last):
File "/data/data/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 29, in <module> start(fakepyfile,mainpyfile) File "/data/data/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 28, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 6, in <module> File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/flask/__init__.py", line 21, in <module> from .app import Flask, Request, Response File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/flask/app.py", line 25, in <module> from . import cli, json File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/flask/json/__init__.py", line 21, in <module> from itsdangerous import json as _json File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/itsdangerous.py", line 38, in <module> import simplejson as json
File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/simplejson/__init__.py", line 115, in <module>
from .encoder import JSONEncoder, JSONEncoderForHTML
File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/simplejson/encoder.py", line 15, in <module>
c_encode_basestring_ascii, c_make_encoder = _import_speedups()
File "/data/data/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.6/site-packages/simplejson/encoder.py", line 12, in _import_speedups
return _speedups.encode_basestring_ascii, _speedups.make_encoder
AttributeError: module 'markupsafe._speedups' has no attribute 'encode_basestring_ascii'

I suggest you to use pipenv and try it again.
pip install pipenv
pipenv shell --three
pipenv install flask

Related

ModuleNotFoundError: No module named 'greenlet._greenlet'

I'm trying to use the TikTokPy but there is an error occurring in Greenlet module:
$ python quickstart.py
Traceback (most recent call last):
File "C:\Users\mngoc\tiktokpy\quickstart.py", line 2, in <module>
from tiktokpy import TikTokPy
File "C:/Users\mngoc\tiktokpy/tiktokpy/__init__.py", line 1, in <module>
from .bot import TikTokPy
File "C:/Users\mngoc\tiktokpy/tiktokpy/bot/__init__.py", line 15, in <module>
from tiktokpy.client import Client
File "C:/Users\mngoc\tiktokpy/tiktokpy/client/__init__.py", line 8, in <module>
from playwright.async_api import Browser, Page, Playwright, PlaywrightContextManager, Response
File "C:/Users\mngoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages/playwright/async_api/__init__.py", line 25, in <module>
import playwright.async_api._generated
File "C:/Users\mngoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages/playwright/async_api/_generated.py", line 25, in <module>
from playwright._impl._accessibility import Accessibility as AccessibilityImpl
File "C:/Users\mngoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages/playwright/_impl/_accessibility.py", line 17, in <module>
from playwright._impl._connection import Channel
File "C:/Users\mngoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages/playwright/_impl/_connection.py", line 23, in <module>
from greenlet import greenlet
File "C:/Users\mngoc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages/greenlet/__init__.py", line 29, in <module>
from ._greenlet import _C_API # pylint:disable=no-name-in-module
ModuleNotFoundError: No module named 'greenlet._greenlet'
I've already installed Greenlet module, but I have no idea about ._greenlet, there isn't any answer for related question so I'm stuck.
You should install the module:
pip3 install greenlet

Cant install pip on mac? Using VS code

whenever i use the terminal and type pip3 install requests this is what happens:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3", line 11, in <module>
sys.exit(main())
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/__init__.py", line 13, in main
from pip._internal.utils.entrypoints import _wrapper
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/utils/entrypoints.py", line 4, in <module>
from pip._internal.cli.main import main
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/configuration.py", line 21, in <module>
from pip._internal.exceptions import (
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/exceptions.py", line 8, in <module>
from pip._vendor.requests.models import Request, Response
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/__init__.py", line 123, in <module>
from . import utils
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/utils.py", line 27, in <module>
from ._internal_utils import to_native_string
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str, str
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/compat.py", line 63, in <module>
from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment
ImportError: cannot import name 'parse_http_list' from 'urllib.request' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py)
Is there something I did wrong?
Try running pip3 install --upgrade pip
then try again with pip3 install requests

python TypeError: 'type' object is not iterable error

I am getting an error message when I try to run a python script, the python script I am attempting to run is https://raw.githubusercontent.com/orangetw/awesome-jenkins-rce-2019/master/exp.py I don't think that this is an issue with the script as I am able to run this on my host OS (having run the script in as OS)
Traceback (most recent call last):
File "exp.py", line 7, in <module>
import requests
File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in <module>
from urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/kali/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/home/kali/.local/lib/python2.7/site-packages/OpenSSL/crypto.py", line 12, in <module>
from cryptography import x509
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/base.py", line 18, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/extensions.py", line 26, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/general_name.py", line 16, in <module>
from cryptography.x509.name import Name
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/name.py", line 28, in <module>
_ASN1_TYPE_TO_ENUM = {i.value: i for i in _ASN1Type}
TypeError: 'type' object is not iterable
line 7 is
import requests
Help appreciated

Unable to install Python pip or use easy_install

I am on OSX 10.10.3 with Python 2.7.6 as my main Python. I suddenly ran into trouble using pip, and tried to fix it. The solution proposed elsewhere on StackOverflow was to remove installations of pip and reinstall it either using their official installer or using easy_install.
Running the installation script (https://bootstrap.pypa.io/get-pip.py) gives:
Traceback (most recent call last):
File "pip.py", line 17767, in <module>
main()
File "pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpDnRtQK/pip.zip/pip/__init__.py", line 6, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 90, in <module>
from gettext import gettext
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 110, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
and running "sudo easy_install pip" gives
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 581, in resolve
requirements.extend(dist.requires(req.extras)[::-1])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2323, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2374, in __getattr__
raise AttributeError(attr)
AttributeError: _dep_map
I am not really sure where to go next.
I am also in the situation that I can't import various modules, for example Flask, since I get the following error:
Traceback (most recent call last):
File "/Users/dawi/git/friends/run.py", line 2, in <module>
from application import app
File "/Users/dawi/git/friends/application/__init__.py", line 3, in <module>
from flask import Flask
File "/Library/Python/2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wrappers.py", line 23, in <module>
from functools import update_wrapper
ImportError: cannot import name update_wrapper

Amazon Elastic Beanstalk CLI issues on linux: zlib error

I am trying to use elastic beanstalk cli on an amazon linux instance and I always get zlib module error. This probably is more to do with my linux/unix ignorance but please send any inputs you have.
$ eb init
Traceback (most recent call last):
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/eb", line 17, in <module>
from scli import core
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/scli/core .py", line 24, in <module>
from scli import command, cli_parse, config_file, prompt
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/scli/comm and.py", line 18, in <module>
from scli.operation_queue import OperationQueue
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/scli/oper ation_queue.py", line 19, in <module>
from scli.operation.base import OperationBase
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/scli/oper ation/base.py", line 21, in <module>
from lib.elasticbeanstalk import eb_utils
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/lib/elast icbeanstalk/eb_utils.py", line 22, in <module>
from scli import api_wrapper
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/scli/api_ wrapper.py", line 19, in <module>
from lib.elasticbeanstalk.servicecall import ElasticBeanstalkClient
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/lib/elast icbeanstalk/servicecall.py", line 23, in <module>
from lib.aws.webservice import AWSQueryClient, AWSSignature
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/lib/aws/w ebservice.py", line 26, in <module>
from . import requests
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/lib/aws/r equests/__init__.py", line 52, in <module>
from . import utils
File "/home/ec2-user/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python3/lib/aws/r equests/utils.py", line 18, in <module>
import zlib
ImportError: No module named zlib

Categories

Resources