import "unittest2" could not be resolved Pylance - python

I'm getting this error in my Python code for raspberry pi.
import os
import subprocess
import sys
import warnings
import time
from threading import Timer
import RPi.GPIO as GPIO
if sys.version[:3] == '2.6':
import unittest2 as unittest
else:
import unittest

Related

What is the requirements.txt, what should be in it?

I am switching from replit to pebblehost to host my python bot. What do I put in my requirements.txt?
These are the imports that I have at the start of my bot.
import asyncio
import datetime
import functools
import io
import json
import os
import random
import re
import string
import urllib.parse
import urllib.request
import time
from urllib import parse, request
from itertools import cycle
from bs4 import BeautifulSoup as bs4
import cloudscraper
import discord, time
import random, threading
import asyncio
from discord.ext import commands
import aiohttp
import colorama
import discord
import numpy
import requests
from time import sleep
from discord import Permissions
from discord.ext import commands
from discord.utils import get
You just write the Packages you‘ve installed in it.
If you write >= 1.17 the version has to be higher than 1.17
Like:
Discord.py
Pillow

Python ImportError when building exe

I have a python code which i'm converting into exe
The code is working fine in development when i'm running code in terminal
This error is coming when i'm opening the exe
My script modules
from tkinter import *
import tkinter as tk
from PIL import ImageTk, Image
from tkinter import messagebox
import pymysql
import time
import pyautogui
import datetime
from datetime import datetime as dt
from datetime import datetime as dt1
import win32gui
import psutil
import os
import requests
import win32process
import operator
import random, string
import threading
import sys
import os.path
from ctypes import Structure, windll, c_uint, sizeof, byref
from tkinter import messagebox
from pynput.keyboard import Key, Listener
import logging
Possible error is comng from here i think - from pynput.keyboard import Key, Listener
Try build exe this way:
install pyinstaller: pip install pyinstaller
Open cdm -> navigate to folder -> enter following command:
pyinstaller.exe --onefile --icon=myicon.ico --windowed app.py
--onefile : create only .exe in one file not in folder with many files
--icon: if you have icon you want to use for .exe file
--windowed: to open windowed mode.

Can't import class and module on Python progrram

I do not program on Python, so I don't know what the problem is.
I just can't start the program from the command line, this is displayed:
Here is code __init__.py
import os
import sys
from PyQt4 import QtGui, QtCore
from pynfb.experiment import Experiment
from pynfb.io.xml_ import xml_file_to_params
from pynfb.settings_widget.general import GeneralSettingsWidget
from pynfb.settings_widget.inlet import InletSettingsWidget
from pynfb.settings_widget.protocol_sequence import ProtocolSequenceSettingsWidget
from pynfb.settings_widget.protocols import ProtocolsSettingsWidget, FileSelectorLine
from pynfb.settings_widget.signals import SignalsSettingsWidget
from pynfb.settings_widget.composite_signals import CompositeSignalsSettingsWidget
from pynfb.settings_widget.protocols_group import ProtocolGroupsSettingsWidget
static_path = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + '/static')
class SettingsWidget(QtGui.QWidget):
You need to install PyQt4 first: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Download the correct file corresponding to the version of your python, e.g. PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl then install by using pip (https://pip.pypa.io/en/stable/installing/)
pip install PyQt4-4.11.4-cp37-none-win_amd64.whl

ModuleNotFoundError: No module named 'gevent.wsgi'

I'm getting the following error while running a flask app:
from gevent.wsgi import WSGIServer
ModuleNotFoundError: No module named 'gevent.wsgi'
gevent is already installed and the requirement is satisfied.
Pip version is 10.11 and Python 3.6.
OS: Windows 10 x64
Using Anaconda VM
This same code worked in another machine, so somewhere I am missing configuration, but I can't track/find it.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import logging
import json
from pprint import pprint
from rasa_core.channels import HttpInputChannel
from rasa_core import utils
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.channels.channel import UserMessage
from rasa_core.channels.direct import CollectingOutputChannel
from rasa_core.channels.rest import HttpInputComponent
from flask import Blueprint, request, jsonify, abort
def run(serve_forever=True):
#path to your NLU model
interpreter = RasaNLUInterpreter("models/nlu/default/current")
# path to your dialogues models
agent = Agent.load("models/dialogue", interpreter=interpreter)
#http api endpoint for responses
input_channel = SimpleWebBot()
if serve_forever:
agent.handle_channel(HttpInputChannel(5004, "/chat", input_channel))
return agent
if __name__ == '__main__':
utils.configure_colored_logging(loglevel="INFO")
run()
Try using:
from gevent.pywsgi import WSGIServer
Instead of:
from gevent.wsgi import WSGIServer
The import statement you quoted needs to be updated to:
from gevent.pywsgi import WSGIServer
The gevent.wsgi module has been deprecated and was removed when gevent 1.3 was released. Its replacement is the gevent.pywsgi module, which has been around for some time.
It looks like in your case, the rasa-core library you're using is the one with the bad import line. This was fixed starting in the 0.9.0 release, so you should update that dependency to a newer version.

tornado.database Importerror: No module named database

I'm using a fork of Bret Taylor's 'socialcookbook' (https://github.com/finiteloop/socialcookbook) which uses "import tornado.database" - and it's worked perfectly until yesterday (the 3.01 build?) and now I'm getting an ImportError: no module named database when I compile on Heroku (using Python).
My requirements.txt file is simple:
mysql-python
tornado
My import statements:
import base64
import datetime
import functools
import json
import hashlib
import hmac
import time
import logging
import os
import smtplib #for mandrill email notifications
import httplib #for custom error handler
import re
import string
import tornado.database
import tornado.escape
import tornado.httpclient
import tornado.ioloop
import tornado.web
import urllib
import urllib2
import urlparse
from tornado.options import define, options
import facebook
Any thoughts? I'm having a hard time troubleshooting this one and I can't push new builds (old builds work fine if I rollback on Heroku, though, oddly..)
As it turns out, Tornado 3.0 has deprecated tornado.database and replace it with torndb: https://github.com/bdarnell/torndb
So the fix is to simply replace all tornado.database references with torndb and add torndb to the requirements.txt file.

Categories

Resources