I'm trying to load the package enthought.mayavi.mlab in python's spider enviorment:
import enthought.mayavi.mlab as mlb
And I get the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 487, in runfile
execfile(filename, namespace)
File "C:\Users\Eytan\Desktop\Mah\PyBrainTraining.py", line 2, in <module>
import enthought.mayavi.mlab as mlb
File "C:\Python27\lib\site-packages\enthought\mayavi\mlab.py", line 3, in <module>
from mayavi.mlab import *
File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 25, in <module>
from engine_manager import get_engine
File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
from preference_manager import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "C:\Python27\lib\site-packages\traitsui\api.py", line 35, in <module>
from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\__init__.py", line 22, in <module>
from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\api.py", line 10, in <module>
from .code_editor import CodeEditor
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 36, in <module>
class ToolkitEditorFactory ( EditorFactory ):
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 48, in ToolkitEditorFactory
mark_color = Color( 0xECE9D8 )
File "C:\Python27\lib\site-packages\traits\traits.py", line 487, in __call__
return self.maker_function( *args, **metadata )
File "C:\Python27\lib\site-packages\traits\traits.py", line 1183, in Color
return ColorTrait( *args, **metadata )
File "C:\Python27\lib\site-packages\traitsui\toolkit_traits.py", line 7, in ColorTrait
return toolkit().color_trait( *args, **traits )
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 109, in toolkit
_toolkit = _import_toolkit(ETSConfig.toolkit)
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 51, in _import_toolkit
return __import__( name, globals=globals(), level=1 ).toolkit
File "C:\Python27\lib\site-packages\traitsui\qt4\__init__.py", line 18, in <module>
import pyface.qt
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 35, in <module>
prepare_pyqt4()
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 17, in prepare_pyqt4
sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1
anyone knows how to fix it?
Edit: If it will help, I see think that the problem is explained in the last column:
ValueError: API 'QString' has already been set to version 1
Edit: I tried changing API selection for QString and QVariant objects to Api #1,#2. didn't help.
Tried either to set the "Ignore API change errors" to true, didn't help.
Tried EST_TOOLKIT from 'qt4' to 'wx'.
It might be because spider itself uses the QT library and has already initialized it.
According to this http://pythonhosted.org/spyder/installation.html you could use PySide instead of PyQt4 (but i don't know if that's a configuation option or a fallback).
Related
I just tried to use py5 in thonny, but everytime i have the py5 mode on and try to run a code i get a bunch of error messeges, i dont really know what they mean so maybe somebody can help me out ?
thanks in advance
This is the error im always getting
Traceback (most recent call last):
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 52, in <module>
main()
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 44, in main
imported.run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 135, in run_code
_run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 259, in _run_code
_run_sketch(sketch_path, classpath, exit_if_error)
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 196, in _run_sketch
import py5
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5\__init__.py", line 84, in <module>
from py5_tools.magics import load_ipython_extension # noqa
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\__init__.py", line 22, in <module>
from .drawing import DrawingMagics, DXFDrawingMagic
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\drawing.py", line 27, in <module>
from IPython.display import display, SVG, Image
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\__init__.py", line 51, in <module>
from .core.application import Application
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\application.py", line 26, in <module>
from IPython.core import release, crashhandler
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\ultratb.py", line 101, in <module>
import stack_data
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\__init__.py", line 1, in <module>
from .core import Source, FrameInfo, markers_from_ranges, Options, LINE_GAP, Line, Variable, RangeInLine, \
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\core.py", line 19, in <module>
from stack_data.utils import (
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\utils.py", line 11, in <module>
from asttokens import ASTText
ImportError: cannot import name 'ASTText' from 'asttokens' (C:\Users\schwe\AppData\Local\Programs\Thonny\lib\site-packages\asttokens\__init__.py)
I received a response from the py5 developer via Github. They also provided an explanation but it goes over my head, something about "The Python library asttokens is used for parsing syntax trees and syntax highlighting. It is not used by py5 but it might be used by Jupyter Notebook and/or JupyterLab.". They also provided a solution here:
enter link description here
I am using python 3.5 and installed tensorflow-gpu 1.12.0 on Linux. When I run this in python3.5:
import tensorflow as tf
It works fine with no errors.
However, when I run:
import tensorflow.contrib
There is an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/__init__.py", line 49, in <module>
from tensorflow.contrib import distributions
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/distributions/__init__.py", line 38, in <module>
from tensorflow.contrib.distributions.python.ops.estimator import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/distributions/python/ops/estimator.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.estimators.head import _compute_weighted_loss
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/__init__.py", line 96, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/__init__.py", line 28, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 30, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 302, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 35, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 36, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 52, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 26, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 33, in <module>
import dask.dataframe as dd
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/dataframe/__init__.py", line 1, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 23, in <module>
from .. import array as da
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/array/__init__.py", line 4, in <module>
from .core import (Array, stack, concatenate, take, tensordot, transpose,
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/array/core.py", line 13, in <module>
from toolz.curried import (pipe, partition, concat, unique, pluck, join, first,
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 53, in <module>
_curry_namespace(vars(toolz)),
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in _curry_namespace
for name, f in ns.items() if '__' not in name
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in <genexpr>
for name, f in ns.items() if '__' not in name
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 42, in _should_curry
return (callable(f) and _nargs(f) > 1 or f in do_curry)
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 35, in _nargs
return len(inspect.getargspec(f).args)
File "/home/myname/anaconda3/lib/python3.5/inspect.py", line 1050, in getargspec
raise ValueError("Function has keyword-only arguments or annotations"
ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
I searched for getfullargspec() API but got even more confused. As far as I know, the getfullargspec() API from inspect can only do with something like
getfullargsspec(function_name)
How can I do with it? I could appreciate it a lot if you could explain the cause and also possibly a simple solution.
Plus, I am running the code on a remote server without root permission. Command lines such as
sudo xxxxx
do not work for me.
Thank you for your help!
I also face this problem. I found this way to solve this problem.
conda install toolz
Good Luck
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()
I'm getting the following error when trying to import models into my google app engine app:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/app/0-1.405524594589080344/main.py", line 6, in <module>
from BaseHandler import BaseHandler
File "/base/data/home/apps/app/0-1.405524594589080344/BaseHandler.py", line 26, in <module>
from user.database import u_db
File "/base/data/home/apps/app/0-1.405524594589080344/user/database/u_db.py", line 12, in <module>
from clubs.database import fed_db, league_db, club_db
File "/base/data/home/apps/app/0-1.405524594589080344/clubs/database/fed_db.py", line 6, in <module>
from events.database import e_db
File "/base/data/home/apps/app/0-1.405524594589080344/events/database/e_db.py", line 7, in <module>
from user.database import u_db
ImportError: cannot import name u_db
I renamed the model files and their container folders, and can see this has something to do with Path.
I would really appreciate some help in fixing this as I am stuck.
Thanks.
You have a circular dependency in your models, see these snippets in your traceback:
File "/base/data/home/apps/app/0-1.405524594589080344/BaseHandler.py", line 26, in <module>
from user.database import u_db
...
File "/base/data/home/apps/app/0-1.405524594589080344/events/database/e_db.py", line 7, in <module>
from user.database import u_db
You need to fix that. Often it can be done simply by moving the import statements inside the functions where they are actually needed instead of just at the top of the file. But not always.
I want to use pwntools(which is python module) in my mac. However I get error instead of pwntools. I tried all step in https://github.com/Gallopsled/pwntools/issues. But I get
Traceback (most recent call last):
File "/Users/Knight/PycharmProjects/untitled/gmail.py", line 1, in <module>
import pwn
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwn/__init__.py", line 2, in <module>
from .toplevel import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwn/toplevel.py", line 20, in <module>
import pwnlib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/__init__.py", line 40, in <module>
importlib.import_module('.%s' % module, 'pwnlib')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/args.py", line 10, in <module>
from . import term
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/__init__.py", line 3, in <module>
from . import completer
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/completer.py", line 4, in <module>
from . import readline
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/readline.py", line 4, in <module>
from . import text
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/text.py", line 115, in <module>
sys.modules[__name__] = Module()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/text.py", line 26, in __init__
self.num_colors = termcap.get('colors', default = 8)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pwnlib/term/termcap.py", line 25, in get
s = curses.tigetstr(cap)
_curses.error: must call (at least) setupterm() first
I can't understand why I can't use it.
Help me please
You must set the following environment variables as indicated here
export TERM=linux
export TERMINFO=/etc/terminfo
Setupterm could not find terminal, in Python program using curses