python3 ImportError: cannot import name 'rand_str' - python

Im getting this error when starting my software i dont know how to repair this
Traceback (most recent call last):
File "/root/findex/lib/python3.5/site-packages/findex_gui/main.py", line 208, in web
run_async()
File "/root/findex/lib/python3.5/site-packages/findex_gui/main.py", line 201, in run_async
from findex_gui.web import app
File "/root/findex/lib/python3.5/site-packages/findex_gui/web.py", line 41, in <module>
from findex_gui.orm.connect import Database
File "/root/findex/lib/python3.5/site-packages/findex_gui/orm/connect.py", line 12, in <module>
from findex_gui.orm.models import BASE
File "/root/findex/lib/python3.5/site-packages/findex_gui/orm/models.py", line 22, in <module>
from findex_common.utils import rand_str
ImportError: cannot import name 'rand_str'

I'm not familiar with the libraries in question, but it seems the maintainer renamed this function in 0.15.14 of findex-common here: development
This has been adjusted for in findex-gui on the master branch though it seems it has not seen a release. Here's the commit which fixes the import: Forgot what I was doing - Ill just push it all ¯_(ツ)_/¯
One short term fix would be to downgrade to findex-common==0.15.13 and perhaps follow up by raising an issue on either project since the change seems non-ideal.

Related

Fix some very minor issues and rebuild sphinx but got the error "wrong color format"

I had some minimal updates in the "source" folder and rebuilt the HTML using make html command. Everything works fine and I synced the folder to GitHub. However, when I was rebuilding the doc on the Read the Docs website, I got an error like this right after cat source/conf.py :
AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
I just added some texts and fixed some typos in my documentation, nothing more. Why this error occurred and the build failed? Thanks.
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 228, in __init__
self.setup_extension(extension)
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
self.registry.load_extension(self, extname)
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
mod = __import__(extname, None, None, ['setup'])
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbsphinx.py", line 41, in <module>
import nbconvert
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbconvert/__init__.py", line 4, in <module>
from .exporters import *
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbconvert/exporters/__init__.py", line 4, in <module>
from .slides import SlidesExporter
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbconvert/exporters/slides.py", line 12, in <module>
from ..preprocessors.base import Preprocessor
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbconvert/preprocessors/__init__.py", line 7, in <module>
from .csshtmlheader import CSSHTMLHeaderPreprocessor
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/nbconvert/preprocessors/csshtmlheader.py", line 14, in <module>
from jupyterlab_pygments import JupyterStyle
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/jupyterlab_pygments/__init__.py", line 4, in <module>
from .style import JupyterStyle
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/jupyterlab_pygments/style.py", line 10, in <module>
class JupyterStyle(Style):
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/pygments/style.py", line 101, in __new__
ndef[0] = colorformat(styledef)
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/pygments/style.py", line 58, in colorformat
assert False, "wrong color format %r" % text
AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/pkg_name/envs/latest/lib/python3.7/site-packages/pygments/style.py", line 58, in colorformat
assert False, "wrong color format %r" % text
AssertionError: wrong color format 'var(--jp-mirror-editor-variable-color)'
The full traceback has been saved in /tmp/sphinx-err-scp_kb7h.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
I had this issue with iPython notebooks since I had an old version of Pygments. Upgrade Pygments with
pip3 install --upgrade Pygments
I was also suffering from the same.In my case that raise due to beacause i update the notebook to the lastest version and left the conda itself to a very old one so it may cause a problem but whem i ran code: pip3 install Pygments==2.6.1it worked perfectly fine for me
This seems to be related to the version of Pygments one is using (see this GitHub issue for details), which needs to be greater than 2.4.1.
In my case, the problem was solved by requiring ReadTheDocs to use: Pygments==2.6.1
I was facing the same issue. For me this got solved by following the steps in Python command fails with AssertionError: wrong color format, basically by installing nbconvert==6.0.0rc0. Thanks

Cant import a PushKit framework into pyobjus

I am trying to import UserNotifications from the PushKit framework but i don't know how to call it because the only Include function i know of in pyobjus is AppKit. I have not seen of any way to call frameworks from the PushKit when i try to call it from the AppKit. it returns an error. Below is my code and the error. I would appreciate any help.
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
UserNotifications = autoclass('UserNotifications')
Traceback
Traceback (most recent call last):
File "/Users/temitayoadefemi/PycharmProjects/test7/mainfile.py", line 5, in <module>
UserNotifications = autoclass('UserNotifications')
File "pyobjus/pyobjus.pyx", line 726, in pyobjus.autoclass
File "pyobjus/pyobjus.pyx", line 85, in pyobjus.MetaObjcClass.__new__
File "pyobjus/pyobjus.pyx", line 116, in pyobjus.MetaObjcClass.resolve_class
pyobjus.ObjcException: Unable to find class b'UserNotifications'
AppKit doesn't have a class called UserNotifications. You could use UNNotificationSettings for normal Push Notification or PKPushRegistry for VoIP Push Notification.
References:
https://developer.apple.com/documentation/pushkit?language=objc
https://developer.apple.com/documentation/usernotifications?language=objc

Bug in Python 3.5? list(globals().items()) caused RuntimeError: dictionary changed size during iteration

This is a part of traceback I've got. And I have no idea how is it possible.
There is no multi-threading (I think). But even if there is a thread which is changing gloabls() is it possible to change globals() during list creation? I thought list() call is protected with GIL, isn't it?
I reproduced it twice, but now I can't reproduce it.
Do you have any ideas how is it possible?
Source code: https://github.com/python/cpython/blob/3.5/Lib/lib2to3/pgen2/token.py#L73
Python 3.5.2, CentOS Linux release 7.4.1708
from past.builtins import basestring
File "/home/user/app/lib64/python3.5/site-packages/past/__init__.py", line 88, in <module>
from past.translation import install_hooks as autotranslate
File "/home/user/app/lib64/python3.5/site-packages/past/translation/__init__.py", line 41, in <module>
from lib2to3.pgen2.parse import ParseError
File "/usr/lib64/python3.5/lib2to3/pgen2/parse.py", line 14, in <module>
from . import token
File "/usr/lib64/python3.5/lib2to3/pgen2/token.py", line 73, in <module>
for _name, _value in list(globals().items()):
RuntimeError: dictionary changed size during iteration

Pyfolio Import Error

When I simply just import pyfolio, I found this error. I've searched on internet, I found some posts saying it's the API issue BTW data provider and pandas(never able to get yahoo data anyway). However, I couldn't find a way to solve it. Is there anyone can help me with this please?
Thanks a lot for your time.
My version of pandas and pyfolio is below:
pyfolio(0.8.0)
pandas(0.20.3)
pandas-datareader(0.3.0.post0)
import pyfolio
Traceback (most recent call last):
File "", line 1, in
import pyfolio
File "C:\Users\user\Anaconda3\lib\site-packages\pyfolio__init__.py", line 3, in
from . import utils
File "C:\Users\user\Anaconda3\lib\site-packages\pyfolio\utils.py", line 24, in
import empyrical.utils
File "C:\Users\user\Anaconda3\lib\site-packages\empyrical__init__.py", line 21, in
from .stats import (
File "C:\Users\user\Anaconda3\lib\site-packages\empyrical\stats.py", line 23, in
from .utils import nanmean, nanstd, nanmin, up, down, roll, rolling_window
File "C:\Users\user\Anaconda3\lib\site-packages\empyrical\utils.py", line 26, in
from pandas_datareader import data as web
File "C:\Users\user\Anaconda3\lib\site-packages\pandas_datareader__init__.py", line 3, in
from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
File "C:\Users\user\Anaconda3\lib\site-packages\pandas_datareader\data.py", line 7, in
from pandas_datareader.google.daily import GoogleDailyReader
File "C:\Users\user\Anaconda3\lib\site-packages\pandas_datareader\google\daily.py", line 1, in
from pandas_datareader.base import _DailyBaseReader
File "C:\Users\user\Anaconda3\lib\site-packages\pandas_datareader\base.py", line 13, in
from pandas_datareader._utils import (RemoteDataError, SymbolWarning,
File "C:\Users\user\Anaconda3\lib\site-packages\pandas_datareader_utils.py", line 5, in
from pandas.core.common import PandasError
ImportError: cannot import name 'PandasError'
Seems to be issue with PyFolio release.
Look at similar issue at GitHub.
Install latest version from clone of GitHub
repository , that should solve the issue otherwise you need to open a issue at GitHub.
There are similar issues about Yahoo URL failures on the site.
You seem to have old version of pandas-datareader latest version is 0.6.0 as of today. And please see that Yahoo API has been deprecated lately
Warning
As of v0.6.0 Yahoo!, Google Options, Google Quotes and EDGAR have been
immediately deprecated due to large changes in their API and no stable
replacement.

Import error when using XPath from PyXML-0.8.4

I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. For Xpath, I'm using the xpath module provided in PyXml-0.8.4.
However, the import line itself throws the following error:
Traceback (most recent call last):
File "xp.py", line 7, in <module>
from xml.xpath import Evaluate
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/__init__.py", line 112, in <module>
from pyxpath import ExprParserFactory
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/pyxpath.py", line 59, in <module>
from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
^
SyntaxError: invalid syntax
Looking it up led me to understand that this is because 'as' is a reserved name in python-2.6 and PyXML-0.8.4 tries to redefine it. However, there are no directions on how to resolve this issue.
Please advise.
PyXML is obsolete and should not be used (see here). That's why there are no updates for it. Many features that were included in it were added to Python's standard library. There are also fully-supported third-party packages for Python XML processing like lxml.

Categories

Resources