Re: [Tutor] Error: 'IndexedVar' object is not callable
Hi everyone, I am sorry about the confusion earlier, I am trying to run Pyomo environment in Python on sublime text editor. Python version of 2.7.11. I am running the code in sublime itself. The code is somewhat long, around 200 lines. I can add snippets of it though. Code: m.z = ContinuousSet(bounds = (0,10)) m.t = ContinuousSet(bounds = (0,10)) where all the variables that I am defining, are varying along the z and t direction. Variables: m.C = Var(m.z,m.t) m.Cair = Var(m.z,m.t) m.masswater = Var(m.z,m.t) m.massair = Param(initialize = 1833.50) that is C and Cair and all other variables are varying along z and t direction. After this, when I define the equations, def _calculations(m,i,j): if i == 0 or i == 1 or j == 0: return Constraint.Skip return m.wateraccumulated(j) == 916.50 - (m.C(i,j)*46*28/(28*18*1.205 + m.C(i,j) * 46*28))*2750 if i == 0: return m.vel(i,j) == m.inmassflowrate/ ((m.outerdiameter * m.outerdiameter * m.pi/4)*m.densityfeed) if i == 1: return m.vel(i,j) == m.outmassflowrate/((m.outerdiameter * m.outerdiameter * m.pi/4)*m.densityfeed) return m.vel(i,j) == m.flowrate/((m.outerdiameter * m.outerdiameter * m.pi/4)*m.densityfeed) m.calculations = Constraint(m.z,m.t, rule = _calculations) It tells me that TypeError: 'IndexedVar' object is not callable for m.C itself. I think the syntax is correct but I am not able to figure out why the variable is not callable. I am aware that the language is slightly different than Python here, I am just stuck and would appreciate any help here. On Fri, Sep 9, 2016 at 9:49 PM, Alex Kleider wrote: > On 2016-09-09 18:13, Steven D'Aprano wrote: > >> Please read this article first for >> how you can improve the chances of getting good answers to your >> questions: >> >> http://sscce.org/ >> > > In addition to the link Seven provides above, I've also found the > following to be worth perusing: > http://www.catb.org/esr/faqs/smart-questions.html > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error: 'IndexedVar' object is not callable
On 10/09/16 17:23, Pooja Bhalode wrote: > I am trying to run Pyomo environment in Python on sublime text editor. OK, For the pyomo stuff you should ask on the pyomo support site (or I notice they do staxck overflow too) > Python version of 2.7.11. I am running the code in sublime itself. You maybe should try running it outside Sublime, it may give you more useful error messages. > Code: > > m.z = ContinuousSet(bounds = (0,10)) > m.t = ContinuousSet(bounds = (0,10)) > where all the variables that I am defining, are varying along the z and t > direction. Most of that is mreaningless to us because we don;t know pyomo. I'd never even heard of it until you said. > Variables: > m.C = Var(m.z,m.t) > m.Cair = Var(m.z,m.t) > m.masswater = Var(m.z,m.t) > m.massair = Param(initialize = 1833.50) Again that is all very pyomo specific. Its hard to comment without knowing pyomo. > After this, when I define the equations, > > def _calculations(m,i,j): > if i == 0 or i == 1 or j == 0: > return Constraint.Skip > > return m.wateraccumulated(j) == 916.50 - (m.C(i,j)*46*28/(28*18*1.205 + > m.C(i,j) * 46*28))*2750 What happens if you do: m.C = Var(m.z,m.t) print m.C print m.C(i,j) > It tells me that TypeError: 'IndexedVar' object is not callable for m.C > itself. I think the syntax is correct but I am not able to figure out why > the variable is not callable. Its not clear where the error is occurring, are you sure that's all the error message says?? Usually there is a whole heap of stuff about where the call happened and its context. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] pip says no downloads for PyMedia
I am working on an exercise that needs PyMedia. pypi seems to have the package but will not download it. jfb@Jims-1404:~$ pip3 search PyMedia pymediafire - A python package for MediaFire API ffmpymedia- Wrapper around the FFMPEG utility PyMedia - PyMedia is a module/library for manipulating mp3, avi, ogg, divx, mpeg, dvd media files pymedia2-pyrana - Package for simple manipulation of multimedia files pymediainfo - A Python wrapper for the mediainfo library. PyMediaRSS2Gen- A Python library for generating Media RSS 2.0 feeds. jfb@Jims-1404:~$ sudo pip3 install PyMedia [sudo] password for jfb: Downloading/unpacking PyMedia Could not find any downloads that satisfy the requirement PyMedia Cleaning up... No distributions at all found for PyMedia Storing debug log for failure in /home/jfb/.pip/pip.log jfb@Jims-1404:~$ From pip.log: /usr/bin/pip3 run on Sat Sep 10 19:04:34 2016 Downloading/unpacking PyMedia Getting page https://pypi.python.org/simple/PyMedia/ URLs to search for versions for PyMedia: * https://pypi.python.org/simple/PyMedia/ Analyzing links from page https://pypi.python.org/simple/pymedia/ Could not find any downloads that satisfy the requirement PyMedia Cleaning up... Removing temporary dir /tmp/pip_build_root... No distributions at all found for PyMedia Exception information: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "/usr/lib/python3/dist-packages/pip/req.py", line 1178, in prepare_files url = finder.find_requirement(req_to_install, upgrade=self.upgrade) File "/usr/lib/python3/dist-packages/pip/index.py", line 277, in find_requirement raise DistributionNotFound('No distributions at all found for %s' % req) pip.exceptions.DistributionNotFound: No distributions at all found for PyMedia I am using python3 could that be the problem? I looked but couldn't find any info on what version of python is needed. Thanks, Jim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor