This question already has answers here:
install python collections
(2 answers)
Closed 6 years ago.
from collections import Counter
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name Counter
Counter is only supported in python2.7 and higher and is not available in earlier versions - Counter class got added into collections package in Python 2.7
Related
This question already has answers here:
How to check MouseButtonPress event in PyQt6?
(2 answers)
Closed 11 months ago.
In PyQt5 I use this code to hide the Windows Dialog help question mark. I cannot find an equivalent flag in PyQt6.
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
Resolved, its namespace is:
Qt.WindowType.WindowContextHelpButtonHint
I am using pyomo Pyomo 5.1.1 (CPython 3.6.0 on Linux 3.16.0-4-amd64)
under Python 3.6, and I get an error message when I want to build an Expression in a model using a summation.
Here is a minimal example :
from pyomo.environ import *
from pyomo.opt import SolverFactory
model=ConcreteModel()
model.H=RangeSet(0,23)
model.x=Var(model.H)
E=summation(model.x)
I get the following error :
"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/util.py", line 86, in summation
ans += item
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/numvalue.py", line 537, in __iadd__
return generate_expression(_iadd,self,other)
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/expr_coopr3.py", line 977, in generate_expression
_self = _generate_expression__clone_if_needed(_self, 1)
File "/home/b67777/anaconda3/lib/python3.6/site-packages/pyomo/core/base/expr_coopr3.py", line 918, in _generate_expression__clone_if_needed
% ( getrefcount(obj) - UNREFERENCED_EXPR_COUNT, ))
RuntimeError: Expression entered generate_expression() with too few references (0<0); this is indicative of a SERIOUS ERROR in the expression reuse detection scheme.
"
I get the same error if I replaced the "summation" by a loop over h in model.H.
The bug has been noticed also here : https://github.com/Pyomo/pyomo/issues/103
Is there a simple way to fix this, other than stepping back to older version of Python ?
Thank you very much for your help,
Paulin
Pyomo only supports Python 2.6, 2.7, 3.3, 3.4, and 3.5.
Python 3.6 changed the internal call stack, which invalidated the internal "magic numbers" that Pyomo uses for detecting when an expression is being pointed to by extra variables (i.e., it is potentially being reused in multiple expressions - something that is not allowed by the Pyomo expression trees). The developers are working on a fix (in the pyomo4-expressions branch). Until that fix is merged back into master and released, the only alternative is to install one of the supported Python versions.
Update [3 April 17]: The fix was merged back into master on 7 March 2017. Pyomo should support Python 3.6 in the next patch release.
Update [14 May 17]: Pyomo 5.2 has been released, which provides full support for Python 3.6
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 7 years ago.
Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/wp-includes/functions.php:3198) in /home/*****/public_html/wp-includes/option.php on line 773
How To Fix ?
Something is writing to the output buffer in advance of WordPress try to set the headers, resulting in the error you see. Usually this is a space or other character at the beginning of one of your files (not option.php, this is the file trying to set a header(), the error is probably in your theme or wp-config.php).
Remove the code that is sending the text (whatever it may be) and the error will go away.
I'm trying to use the rmagic extension for the IPython notebook, using Python 2.7.6 via Enthought Canopy.
When I try the following example:
import numpy as np
import pylab
X = np.array([0,1,2,3,4])
Y = np.array([3,5,4,6,7])
pylab.scatter(X, Y)
%Rpush X Y
%R lm(Y~X)$coef
I get an error:
AttributeError Traceback (most recent call last)
<ipython-input-7-96dff2c70ba0> in <module>()
1 get_ipython().magic(u'Rpush X Y')
----> 2 get_ipython().magic(u'R lm(Y~X)$coef')
…
/Users/hrob/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/extensions/rmagic.pyc in eval(self, line)
212 res = ro.r("withVisible({%s})" % line)
213 value = res[0] #value (R object)
--> 214 visible = ro.conversion.ri2py(res[1])[0] #visible (boolean)
215 except (ri.RRuntimeError, ValueError) as exception:
216 warning_or_other_msg = self.flush() # otherwise next return seems to have copy of error
AttributeError: 'module' object has no attribute 'ri2py'
I can't find anyone else who's had the same problem and don't know enough to solve it myself. There is no definition for ri2py in conversion.py though.
I initially had installed Anaconda and was running python notebook through that, with exactly the same results.
rpy2 (version 2.4.0) installed successfully but when I test it I get 1 expected failure as follows:
python -m 'rpy2.robjects.tests.__init__'
…
testNewWithTranslation (testFunction.SignatureTranslatedFunctionTestCase) ... expected failure
I don't know if that's related.
Can anyone suggest what the problem might be and how I might fix it? Are the versions of python, R, etc. that I'm using compatible or do I need to re-install/update something?
Are you using %load_ext rmagic?
If so, try using %load_ext rpy2.ipython instead.
This is one of the new features in version 2.4.0.
This question already has answers here:
Is Sass 3.3 compatible with Compass?
(3 answers)
Closed 7 years ago.
I have a SASS file _button-map-mixin.css that starts with the following associative array:
$cache: (
color: (),
font-size: (),
line-height: (),
background-color: (),
font-family: ()
);
When I compile the file, I get the following error:
Invalid CSS after " color": expected ")", was ": (),"
I don't understand - isn't this valid syntax?
It almost seems like the compiler doesn't recognize an associative array - but I'm using SASS version 3.3.6 (and Compass 0.12.6).
Use sass 3.3.7 and compass 1.0 (it's in alpha gem install compass --pre) If you got wdm related error then also install wdm(require "Ruby Development Kit") gem. If you keep your gem list clean it will be easier to catch dependency errors. Run gem list --local and uninstall all previous versions of compass and sass if you don't need them.