Plenty of these threads but I'm still mega confused. I'm getting a ImportError and I can't figure out what I'm doing wrong...
Heres the error message:
File "/app/src/pptxbuilder/app.py", line 85, in <module>
__web_setup()
File "/app/src/pptxbuilder/app.py", line 35, in __web_setup
from pptxbuilder.views.home import home_bp
File "/app/src/pptxbuilder/views/__init__.py", line 2, in <module>
from .builder import builder_bp
File "/app/src/pptxbuilder/views/builder.py", line 30, in <module>
from pptxbuilder.app import app
File "/app/src/pptxbuilder/app.py", line 85, in <module>
__web_setup()
File "/app/src/pptxbuilder/app.py", line 36, in __web_setup
from pptxbuilder.views.builder import builder_bp
ImportError: cannot import name 'builder_bp'
Here are my paths:
src\pptxbuilder\app.py
src\pptxbuilder\views\builder.py
src\pptxbuilder\views\home.py
In 'builder.py' I have this variable
builder_bp = Blueprint('builder', __name__)
In 'home.py' I have this variable
home_bp = Blueprint('home', __name__)
And I'm running the line below in 'app.py'
'from pptxbuilder.views.builder import builder_bp'
Remove pptxbuilder.
from views.builder import builder_bp
Simple example, but the concept should be the same. Your exact code will be different of course.
Related
I have model trained on colab and now I want to use that in my centOS7-server like this
import json
from flask import Flask, jsonify, request
import mysql.connector as mariadb
from simpletransformers.ner import NERModel,NERArgs
model = NERModel('bert', './checkpoint-14000', use_cuda= False)
model_args = NERArgs()
model_args.lazy_loading = True
app = Flask(__name__)
#app.route('/sp', methods=['POST'])
def addOne():
try:
prediction = model.predict([json.loads(request.data)['txt']])
return jsonify({'OK': prediction[0][0]})
except Exception as e:
return jsonify({'ERROR': e})
if __name__ == '__main__':
app.run(host='0.0.0.0')
I use python3.9
but I got the ERROR
Traceback (most recent call last):
File "/home/milad/flask/./wsgi.py", line 1, in <module>
from myproject import app
File "/home/milad/flask/./myproject.py", line 4, in <module>
from simpletransformers.ner import NERModel,NERArgs
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/__init__.py", line 2, in <module>
from simpletransformers.ner.ner_model import NERModel
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/ner_model.py", line 24, in <module>
from simpletransformers.ner.ner_utils import (
File "/usr/local/lib/python3.9/site-packages/simpletransformers/ner/ner_utils.py", line 33, in <module>
from datasets import load_dataset
File "/usr/local/lib/python3.9/site-packages/datasets/__init__.py", line 37, in <module>
from .arrow_dataset import Dataset, concatenate_datasets
File "/usr/local/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 62, in <module>
from .arrow_reader import ArrowReader
File "/usr/local/lib/python3.9/site-packages/datasets/arrow_reader.py", line 29, in <module>
from .download.download_config import DownloadConfig
File "/usr/local/lib/python3.9/site-packages/datasets/download/__init__.py", line 9, in <module>
from .download_manager import DownloadManager, DownloadMode
File "/usr/local/lib/python3.9/site-packages/datasets/download/download_manager.py", line 29, in <module>
from ..utils.file_utils import cached_path, get_from_cache, hash_url_to_filename, is_relative_path, url_or_path_join
File "/usr/local/lib/python3.9/site-packages/datasets/utils/file_utils.py", line 30, in <module>
from .extract import ExtractManager
File "/usr/local/lib/python3.9/site-packages/datasets/utils/extract.py", line 3, in <module>
import lzma
File "/usr/local/lib/python3.9/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
I find my answer in this just look at the Solution
All of a sudden i am getting below error while running my code in Pycharm. Earlier It was working fine. I tried changing the interpretar from virtual en to base interpreter but no resolve
Traceback (most recent call last):
File "/Users/ubhatia/PycharmProjects/ModerationReport/resources/user_keywords/keyword.py", line 3, in <module>
from robot.api.deco import library, keyword
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/__init__.py", line 43, in <module>
from robot.rebot import rebot, rebot_cli
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/rebot.py", line 40, in <module>
from robot.conf import RebotSettings
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/conf/__init__.py", line 27, in <module>
from .settings import RobotSettings, RebotSettings
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/conf/settings.py", line 16, in <module>
import glob
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/glob.py", line 4, in <module>
import re
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 127, in <module>
import functools
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py", line 21, in <module>
from collections import namedtuple
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/collections/__init__.py", line 22, in <module>
from keyword import iskeyword as _iskeyword
File "/Users/ubhatia/PycharmProjects/ModerationReport/resources/user_keywords/keyword.py", line 3, in <module>
from robot.api.deco import library, keyword
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/api/__init__.py", line 71, in <module>
from robot.model import SuiteVisitor
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/__init__.py", line 28, in <module>
from .body import BaseBody, Body, BodyItem, Branches
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/body.py", line 18, in <module>
from .itemlist import ItemList
File "/Users/ubhatia/.virtualenvs/ModerationReport/lib/python3.7/site-packages/robot/model/itemlist.py", line 17, in <module>
from functools import total_ordering
ImportError: cannot import name 'total_ordering' from 'functools' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py)
This is the piece of code i am running
import time
from datetime import date, timedelta
from robot.api.deco import library, keyword
from robot.libraries.BuiltIn import BuiltIn
import pandas as pd
def get_current_date():
today = time.strftime('%d/%m/%Y')
return today
def get_yesterday_date():
today = date.today()
yesterday = today - timedelta(days=1)
return yesterday.strftime('%d/%m/%Y')
def read_excel_and_change_to_list(excel_path):
return pd.read_excel(excel_path)
print(get_current_date())
Can anyone help me out on how to resolve this issue please?
I have the following error while running a python package cvu(connectome visualization utility):
Traceback (most recent call last):
File "/usr/local/bin/cvu", line 4, in <module>
__import__('pkg_resources').run_script('cvu==0.5.2', 'cvu')
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 657, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1437, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/EGG-INFO/scripts/cvu", line 33, in <module>
from cvu.main import main
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/cvu/__init__.py", line 20, in <module>
from .main import load_adj, load_parc, usage, main
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/cvu/main.py", line 20, in <module>
from gui import CvuGUI,ErrorHandler
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/cvu/gui.py", line 24, in <module>
from dataset import Dataset
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/cvu/dataset.py", line 26, in <module>
from dataview import (DataView,DVMayavi,DVMatrix,DVCircle)
File "/usr/local/lib/python2.7/dist-packages/cvu-0.5.2-py2.7.egg/cvu/dataview.py", line 28, in <module>
from chaco.api import (Plot,ArrayPlotData,ColorMapper,PlotGraphicsContext)
File "/usr/lib/python2.7/dist-packages/chaco/api.py", line 37, in <module>
from abstract_plot_renderer import AbstractPlotRenderer
File "/usr/lib/python2.7/dist-packages/chaco/abstract_plot_renderer.py", line 7, in <module>
from plot_component import PlotComponent
File "/usr/lib/python2.7/dist-packages/chaco/plot_component.py", line 4, in <module>
from enable.api import Component
File "/usr/lib/python2.7/dist-packages/enable/api.py", line 21, in <module>
from markers import MarkerTrait, marker_trait, MarkerNameDict, marker_names, \
File "/usr/lib/python2.7/dist-packages/enable/markers.py", line 18, in <module>
from compiled_path import CompiledPath
File "/usr/lib/python2.7/dist-packages/enable/compiled_path.py", line 17, in <module>
from toolkit import toolkit_object
File "/usr/lib/python2.7/dist-packages/enable/toolkit.py", line 47, in <module>
_init_toolkit()
File "/usr/lib/python2.7/dist-packages/enable/toolkit.py", line 40, in _init_toolkit
format_exception_only(t, v))
ImportError: Unable to import the image backend for the qt4 toolkit (reason: ['ImportError: No module named QtOpenGL\n']).
I have installed this
apt-get install python-qt4-gl
but stil I have the same error.
I don't know what is wrong.
Thanks for any guide.
edit
this is the script that run the pakcage:
run.py
#!/usr/bin/env python
import os
import sys
#pyside can cause problems with old versions of enable
#however, forcing traits to use pyqt causes problems in anaconda
#We will let the user set this optionally, it is good for debugging to not set.
#os.environ['QT_API']='pyqt'
#os.environ['QT_API']='pyside'
#One or the other should usually be set so that matplotlib and pyface can
#communicate and use the right Qt backend
#pyside is a better default choice
scriptdir=os.getcwd()
python_cmd = 'pythonw' if sys.platform=='darwin' else 'python'
#arguments = '%s %s'%(scriptdir, " ".join(sys.argv[1:]))
#exec_cmd = "%s main.py %s" % (python_cmd, arguments)
arguments = '%s main.py %s %s' % (python_cmd, scriptdir, " ".join(sys.argv[1:]))
try:
#see if cvu extracted locally
os.chdir(os.path.join(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))),'cvu'))
os.system(arguments)
except OSError:
#see if cvu installed to system python
from cvu.main import main
sys.argv = arguments.split()
main()
Hey I need help with this python error:
File "bot.py", line 3, in <module>
import telepot
File "/home/lee/venv/telegram/local/lib/python2.7/site-packages/telepot/__init__.py", line 220, in <module>
from . import helper
File "/home/lee/venv/telegram/local/lib/python2.7/site-packages/telepot/helper.py", line 7, in <module>
import inspect
File "/usr/lib/python2.7/inspect.py", line 39, in <module>
import tokenize
File "/usr/lib/python2.7/tokenize.py", line 39, in <module>
COMMENT = N_TOKENS
bot.py
import telepot
bot = telepot.Bot('<bot_token>')
print bot.getMe()
from pprint import pprint
response = bot.getUpdates()
pprint(response)
This error comes about as a result of importing any telegram python module. All help will be appreciated.
I've encountered a very strange error when trying to Import mayavi. A few minutes ago it worked like a charm, but now there's something going wrong and I've no clue why.
I start python from the terminal and then I type:
from mayavi import mlab
The error I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/mayavi/mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/usr/lib/python2.7/dist-packages/mayavi/tools/camera.py", line 23, in <module>
from engine_manager import get_engine
File "/usr/lib/python2.7/dist-packages/mayavi/tools/engine_manager.py", line 14, in <module>
from mayavi.core.engine import Engine
File "/usr/lib/python2.7/dist-packages/mayavi/core/engine.py", line 28, in <module>
from mayavi.core.scene import Scene
File "/usr/lib/python2.7/dist-packages/mayavi/core/scene.py", line 15, in <module>
from mayavi.core.source import Source
File "/usr/lib/python2.7/dist-packages/mayavi/core/source.py", line 19, in <module>
from mayavi.core.module_manager import ModuleManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/module_manager.py", line 19, in <module>
from mayavi.core.lut_manager import LUTManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/lut_manager.py", line 10, in <module>
import subprocess
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
ImportError: cannot import name mlab
What's wrong with Python?
You have a local file named pickle.py; this is being imported instead of the pickle module. This module then tries to import mlab before that module itself has completed importing in a circular import dependency:
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
Note how subprocess tries to import pickle and finds your file instead (the path is relative instead of a full path inside /usr/lib/python2.7/.
Rename pickle.py to something else, you are masking the standard library here.