pip : AttributeError: module ‘lib’ has no attribute ‘Cryptography_HAS_SSL_ST’

So everytime I want to use pip command on Ubuntu 16.04 I get the following error:

 ~ pip3 --version               Traceback (most recent call last):   File "/usr/local/bin/pip3", line 6, in <module>     from pip._internal import main   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/__init__.py", line 40, in <module>     from pip._internal.cli.autocompletion import autocomplete   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>     from pip._internal.cli.main_parser import create_main_parser   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main_parser.py", line 12, in <module>     from pip._internal.commands import (   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/__init__.py", line 6, in <module>     from pip._internal.commands.completion import CompletionCommand   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/completion.py", line 6, in <module>     from pip._internal.cli.base_command import Command   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/base_command.py", line 20, in <module>     from pip._internal.download import PipSession   File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 15, in <module>     from pip._vendor import requests, six, urllib3   File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/requests/__init__.py", line 97, in <module>     from pip._vendor.urllib3.contrib import pyopenssl   File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>     import OpenSSL.SSL   File "/usr/local/lib/python3.5/dist-packages/OpenSSL/__init__.py", line 8, in <module>     from OpenSSL import crypto, SSL   File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 194, in <module>     if _lib.Cryptography_HAS_SSL_ST: AttributeError: module 'lib' has no attribute 'Cryptography_HAS_SSL_ST' 

I tried to reinstall pyOpenSSL but it requires pip to install it with the command:

pip install pyOpenSSL 

which reproduces the same error message. How can I solve this problem, please?

AttributeError at /posts/add/ ‘PostForm’ object has no attribute ‘cleaned_data’

Tenho uma classe PostForm com um método is_valid que valida os campos do formulário, mas ele não está reconhecendo o atributo cleaned_data, sempre que eu tento adicionar um novo post acontece isso:

AttributeError at /posts/add/  'PostForm' object has no attribute 'cleaned_data' 

PostForm

class PostForm(forms.Form): image = forms.ImageField(required=False) content = forms.CharField(widget=forms.Textarea, required=False)  def is_valid(self):     valid = True     image = self.cleaned_data.get('image')     content = self.cleaned_data.get('content')      if image is None and content is None:         self.add_error('Seu post precisa de um texto e/ou uma imagem')         valid = False      return valid  def add_error(self, message):     errors = self._errors.setdefault(forms.forms.NON_FIELD_ERRORS, forms.utils.ErrorList())     errors.append(message) 

View

@login_required def add_post(request):     if request.method == 'POST':     form = PostForm(request.POST, request.FILES)      if form.is_valid():         data_form = form.cleaned_data         Post.objects.create(image=data_form['image'], content=data_form['content'], user=request.user)          return redirect('index')  else:     return redirect('index') 

Ошибка AttributeError: __new_member__ в модуле enum.py

Что делать? Не давно появилась эта ошибка. Когда запускаю скрипт вылезает она. Раньше этого не было.

AttributeError Сообщение = new_member Трассировка стека: C:\Users\Name\AppData\Local\Programs\Python\Python35\lib\enum.py:270 в EnumMeta.getattr

Ошибка есть если в скрипте есть

from vk_api.longpoll import VkLongPoll, VkEventType import vk_api from

Python AttributeError: ‘NoneType’ object has no attribute ‘data’

Есть такой код:

import os import xml.dom.minidom  li =[] for root, dirs, files in os.walk("C:/users/fedyunin_es/desktop/defaultVars"):     for file in files:         if file.endswith(".substvar"):             path = os.path.join(root, file)             print(path)             li.append(path)  for element in li:      doc = xml.dom.minidom.parse(element)     data ={}      for info in doc.getElementsByTagName("globalVariable"):         name = str(info.getElementsByTagName("name")[0].firstChild.data)         value = str(info.getElementsByTagName("value")[0].firstChild.data)         data[name]=value     print(element,"\n",data,"\n") 

И он выпадает в ошибку:

line 19, in <module>     value = str(info.getElementsByTagName("value")[0].firstChild.data) AttributeError: 'NoneType' object has no attribute 'data' 

Вопрос – в чем причина? Первый цикл записывает в переменную li список директорий, в которых хранятся файлы defaultVars.substvar.

AttributeError: ‘str’ object has no attribute ‘confidence’

Estou desenvolvendo um chatbot e gostaria que ele só respondesse se tivesse determinado nível de confiança na resposta.

#Recebe qualquer outra mensagem @bot.message_handler(func=lambda message:True) def mensagem(message):     bot_convencional(message.text)     resposta = open("arquivos/teste", "r")     resposta = resposta.read()     if float(resposta.confidence) > 0.5:         bot.reply_to(message, resposta)     else:         bot.reply_to(message, "Como você está se sentindo?") bot.polling() 

O problema é que quando eu tento usar o confidence dá o erro

if float(resposta.confidence) > 0.5: AttributeError: ‘str’ object has no attribute ‘confidence’

Já usei confidence em outro chatbot e não entendo porque está dando esse problema dessa vez. Alguém pode me ajudar?

Seeing ‘AttributeError: __enter__ ‘when expecting to see Rasa Bot responses

I am trying to follow a post over creating and running a Rasa bot

Steps already did: – I could get all working folders – Got the basic data files – Trained Nlu and Core – launched action server and command line – So here the expectation is User enters Input like ‘Hi or hello’ and then bot responds and continues the chat

Actual results: Seeing below error.

make cmdline python -m rasa_core.run -d models/current/dialogue -u models/current/nlu --endpoints endpoints.yml C:\Python3.6\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.   from ._conv import register_converters as _register_converters 2019-05-14 17:06:45 INFO     root  - Rasa process starting 2019-05-14 17:06:49 INFO     rasa_nlu.components  - Added 'nlp_spacy' to component cache. Key 'nlp_spacy-en'. 2019-05-14 17:07:18.101829: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2019-05-14 17:07:19 INFO     root  - Rasa Core server is up and running on http://localhost:5005 Bot loaded. Type a message and press enter (use '/stop' to exit): Your input ->  hey 127.0.0.1 - - [2019-05-14 17:08:23] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 190 0.254340 Exception in thread Thread-1: Traceback (most recent call last):   File "C:\Python3.6\lib\threading.py", line 916, in _bootstrap_inner     self.run()   File "C:\Python3.6\lib\threading.py", line 864, in run     self._target(*self._args, **self._kwargs)   File "C:\Python3.6\lib\site-packages\rasa_core\channels\console.py", line 114, in record_messages     for response in bot_responses:   File "C:\Python3.6\lib\site-packages\rasa_core\channels\console.py", line 71, in send_message_receive_stream     with requests.post(url, json=payload, stream=True) as r: AttributeError: __enter__  

On preliminary search over forums, seems it is a Python code issue, as I understand it try to get bot responses using ‘WITH’ keyword ?

Any pointers on how can I get it sorted please ? Thanks in advance, Venky

Ajuda com kivy (erro: AttributeError: ‘weakref’ object has no attribute ‘cline_in_traceback’)

Estou aprendendo o kivy (então sou bem virgem no assunto gui) e me deparei com esse erro:

parte importante: AttributeError: ‘weakref’ object has no attribute ‘cline_in_traceback’

execução completa:

[INFO   ] [Logger      ] Record log in /home/albuquerque/.kivy/logs/kivy_19-04-21_53.txt [INFO   ] [Kivy        ] v1.11.0.dev0, git-eec3a30, 20190421 [INFO   ] [Python      ] v3.6.7 (default, Oct 22 2018, 11:32:17)  [GCC 8.2.0] [INFO   ] [Factory     ] 184 symbols loaded [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO   ] [Text        ] Provider: sdl2 [INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO   ] [GL          ] Using the "OpenGL" graphics system [INFO   ] [GL          ] Backend used <sdl2> [INFO   ] [GL          ] OpenGL version <b'4.6.0 NVIDIA 390.116'> [INFO   ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'> [INFO   ] [GL          ] OpenGL renderer <b'GeForce GT 730M/PCIe/SSE2'> [INFO   ] [GL          ] OpenGL parsed version: 4, 6 [INFO   ] [GL          ] Shading version <b'4.60 NVIDIA'> [INFO   ] [GL          ] Texture max size <16384> [INFO   ] [GL          ] Texture max units <32> [INFO   ] [Window      ] auto add sdl2 input provider [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked  Traceback (most recent call last):    File "kivy/properties.pyx", line 840, in kivy.properties.ObservableDict.__getattr__  KeyError: 'box'   During handling of the above exception, another exception occurred:   Traceback (most recent call last):    File "main.py", line 19, in <module>      Test().run()#O método run() inicializa o app    File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/app.py", line 829, in run      root = self.build()    File "main.py", line 16, in build      return Tarefas(["a","b", "c"])    File "main.py", line 10, in __init__      self.ids.box.add_widget(Label(text=tarefa, font_size=30))#procura nos ids da classe no arquivo text.kv o id box    File "kivy/properties.pyx", line 843, in kivy.properties.ObservableDict.__getattr__  AttributeError: 'super' object has no attribute '__getattr__' Exception ignored in: functools.partial(<function _widget_destructor at 0x7f5c199612f0>, 3) Traceback (most recent call last):   File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/uix/widget.py", line 265, in _widget_destructor   File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/lang/builder.py", line 760, in unbind_widget   File "kivy/weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy.__getat 

a tela da interface não chega nem a abrir

a baixo estão os códigos:

main.py

from kivy.app import * #importar os métodos de APPP do kivy from kivy.uix.boxlayout import BoxLayout #empilha os widgets como se fossem caixas from kivy.uix.label import Label from kivy.uix.scrollview import ScrollView  class Tarefas(ScrollView):     def __init__(self, tarefas, **kwargs): #keyword arguments, o incrivel é que ele executa os argumentos colocados a mais         super().__init__(**kwargs)#chama as funções da classe BoxLayout         for tarefa in tarefas:             self.ids.box.add_widget(Label(text=tarefa, font_size=30))#procura nos ids da classe no arquivo text.kv o id box   class Test(App):#primeiro arquivo que o kivy procura (no caso, Text.kv)      def build(self): #Métod o que constroi o aplicativo         return Tarefas(["a","b", "c"])   Test().run()#O método run() inicializa o app 

test.kv

<Tarefas>:     BoxLayout:         id:box #identificação do widget         orientation:"vertical"         size_hint_y:None         height:self.minimum_height 

estou meio que desesperado, então se conseguirem me ajudar, fico desesperadamente agradecido :D:

Python send reply to a gmail error: AttributeError: ‘int’ object has no attribute ‘encode’

I have constructed the following code to reply to an existing email in my gmail account

msg = MIMEMultipart('') msg['From'] = sender msg['To'] = recipient msg['Subject'] = replySubj msg['In-Reply-To'] = uid msg.attach(MIMEText("I received your message"))  server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username, password) server.sendmail(sender, recipient, msg.as_string()) server.quit() 

I keep getting this error –> AttributeError: ‘int’ object has no attribute ‘encode’ which relates to this line

server.sendmail(sender, recipient, msg.as_string()) 

when I remove .as_string() I get this error: TypeError: expected string or bytes-like object

AttributeError: ‘_SubParsersAction’ object has no attribute ‘add_mutually_exclusive_group’

Tengo un codigo que estoy usando argparse y quiero usar add_mutually_exclusive_group en 2 subparsers porque quiero que uno de los 2 sea requerido y me sale este error:

AttributeError: '_SubParsersAction' object has no attribute 'add_mutually_exclusive_group' 

este es mi codigo:

import argparse as ap  main = ap.ArgumentParser() modes = main.add_subparsers() modesp = modes.add_mutually_exclusive_group(required=True)  a = modesp.add_parser('a') b = modesp.add_parser('b')  a.add_argument('--start') a.add_argument('--stop') a.add_argument('--reset')  b.add_argument('--start') b.add_argument('--stop') b.add_argument('--reset')  main.parse_args()