when starting a telegram bot
python3 main.py
Traceback (most recent call last):
File "/home/tg_bot/main.py", line 6, in <module>
import database
File "/home/tg_bot/database.py", line 4, in <module>
from bin.strings import get_now_date
ModuleNotFoundError: No module named 'bin.strings'
there were no errors, suddenly appeared
example from bin strings
def get_now_date():
"""
Получение текущей даты
:return:
"""
now_data = datetime.now()
return now_data.strftime("%d/%m/%Y %H:%M:%S")
Related
I'm trying to use flask-ask library and develope a skill that can make me able to control a robot in ROS with alexa vocal assistant. Python code named "alexa_interface.py" is here.
The skill id number is substituted with my skill id number.
While launching this command
python3 alexa_interface.py
I am getting the following code error.
Tried to install dependencies with pip but getting:
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
Also notice that I am getting this error everytime I use pip to install something. Is pip broken? How can I adjust this?
Thank you.
#! /usr/bin/env python3
from flask import Flask
from ask_sdk_core.skill_builder import SkillBuilder
from flask_ask_sdk.skill_adapter import SkillAdapter
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model import Response
from ask_sdk_model.ui import SimpleCard
app = Flask(__name__)
class LaunchRequestHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return is_request_type("LaunchRequest")(handler_input)
def handle(self, handler_input):
# type: (HandlerInput) -> Response
speech_text = "Ciao, come posso aiutarti?"
handler_input.response_builder.speak(speech_text).set_card(
SimpleCard("Hello World", speech_text)).set_should_end_session(
False)
return handler_input.response_builder.response`
skill_builder = SkillBuilder()
# Register your intent handlers to the skill_builder object
skill_builder.add_request_handler(LaunchRequestHandler())
skill_adapter = SkillAdapter(
skill=skill_builder.create(), skill_id="my-skill-id", app=app)
skill_adapter.register(app=app, route="/")
if __name__=='__main__':
app.run()
```
```
Traceback (most recent call last):
File "alexa_interface.py", line 2, in <module>
from flask import Flask
File "/home/toti/.local/lib/python3.8/site-packages/flask/__init__.py", line 14, in <module>
from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/toti/.local/lib/python3.8/site-packages/jinja2/__init__.py)
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
import requests
File "/home/toti/.local/lib/python3.8/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/home/toti/.local/lib/python3.8/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/toti/.local/lib/python3.8/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/toti/.local/lib/python3.8/site-packages/OpenSSL/rand.py", line 213, in <module>
_lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
Original exception was:
Traceback (most recent call last):
File "alexa_interface.py", line 2, in <module>
from flask import Flask
File "/home/toti/.local/lib/python3.8/site-packages/flask/__init__.py", line 14, in <module>
from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/toti/.local/lib/python3.8/site-packages/jinja2/__init__.py)
```
Try 'flask run --help' for help.
Error: While importing "main", an ImportError was raised:
Traceback (most recent call last):
File "/home/anirudh/Downloads/blinktrustapis-main/main.py", line 9, in
from .apis.appServer import AppServer
ImportError: attempted relative import with no known parent package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/cli.py", line 240, in locate_app
import(module_name)
File "/home/anirudh/Downloads/blinktrustapis-main/main.py", line 11, in
from apis.appServer import AppServer
File "/home/anirudh/Downloads/blinktrustapis-main/apis/appServer.py", line 32, in
from apis.utility import *
File "/home/anirudh/Downloads/blinktrustapis-main/apis/utility.py", line 6, in
from dataprofiler.piiservice.api import ScanTypeEnum, list_detectors, scan_database
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/piiservice/api.py", line 6, in
from dataprofiler.catelogs.api import scan_sources
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/catelogs/api.py", line 13, in
from dataprofiler.catelogs.catalog.db import DbScanner
File "/home/anirudh/Downloads/blinktrustapis-main/dataprofiler/catelogs/catalog/db.py", line 6, in
from databuilder import Scoped
ImportError: cannot import name 'Scoped' from 'databuilder' (/home/anirudh/.local/lib/python3.9/site-packages/databuilder/init.py)
There is a simple script
# -*- coding: utf-8 -*-
import xlwings as xw
import pandas as pd
wb = xw.Book('Excel_Python-1.xlsx')
data_excel = wb.sheets['Данные']
data_pd = data_excel.range('A1:C4').options(pd.DataFrame, header = 1, index = False).value
print(data_pd)
At startup error:
cannot import name 'get_running_loop' from 'asyncio'
Checked that the 'get_running_loop' method is in the events.py module from 'asyncio'.
What could be the problem?
"C:\Program Files\Python_370\python.exe" O:/___Python/__Examples/Excel/excel-1.py
Traceback (most recent call last):
File "O:/___Python/__Examples/Excel/excel-1.py", line 2, in <module>
import xlwings as xw
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
I ran the script interactively. Here's the result:
C:\Windows\system32>python
Python 3.7.0a1 (v3.7.0a1:8f51bb4, Sep 19 2017, 19:32:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # -*- coding: utf-8 -*-
... import xlwings as xw
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python_370\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Program Files\Python_370\python.exe"
* The NumPy version is: "1.20.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
>>>
>>> wb = xw.Book('Excel_Python-1.xlsx')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'xw' is not defined
>>> data_excel = wb.sheets['Данные']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'wb' is not defined
>>> data_pd = data_excel.range('A1:C4').options(
... pd.DataFrame, header = 1, index = False).value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_excel' is not defined
>>> print(data_pd)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_pd' is not defined
But what conclusions to draw from this - I do not know
I'm getting this error when trying to using polyglot library for the first time.
from polyglot.text import Text, Word
word = Text("Preprocessing is an essential step.").words[0]
print(word.morphemes)
here is the full error message.
Traceback (most recent call last):
File "/home/adeesha/PycharmProjects/theme_recomend/plyglot.py", line 2, in <module>
from polyglot.text import Text, Word
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/__init__.py", line 12, in <module>
from .base import Sequence, TokenSequence
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/base.py", line 9, in <module>
from concurrent.futures import ProcessPoolExecutor, as_completed
ImportError: cannot import name 'ProcessPoolExecutor'
the version of Python 3.5.2
how I gonna solve this problem?
I'm having a big problem with the testing framework in IntelliJ using with the python plugin.
When I launch my tests, written using unittest, the tests fail with an import error in the _jb_test_runner file.
I surfed the net for a while, but didn't get a useful solution. See the stacktrace below:
/usr/bin/python3.5 /home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py --path /home/davide/Scrivania/musical-store/test/types/test_person.py
Testing started at 12.35 ...
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
import re, traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Original exception was:
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Process finished with exit code 1
The code does not present any syntax error, but the problem started after a refactoring of the whole project I'm working on.
Thanks in advance.