I am trying to execute the following code that creates a cube in mesh:
import pygmsh as pg
import numpy as np
def generate():
geom = pg.Geometry()
geom.add_box(0, 1, 0, 1, 0, 1, 0.05)
return geom
if __name__ == '__main__':
import meshio
points, cells = pg.generate_mesh(generate())
meshio.write('cube.vtu', points, cells)
I'm getting the following error:
Traceback (most recent call last):
File "C:/Users/200498/PycharmProjects/untitled/pygmsh.py", line 17, in
<module>
points, cells = pg.generate_mesh(generate())
AttributeError: module 'pygmsh' has no attribute 'generate_mesh'
How can I fix that?
You've called your own script "pygmsh", so it's hiding the library you installed. Rename your file to something else.
Related
I have defined the following in an attempt to export HISTORY OUTPUT data at specified nodes from abaqus odb file. It is not clear to me how to resolve this error. Any suggestions?
from odbAccess import
def main():
odb=openOdb('name.odb')
['Spatial acceleration: A1 at Node 84735155 in NSET SENSOR1',
'Spatial acceleration: A2 at Node 84735155 in NSET SENSOR2']
results = []
for i in range(len(new_list)):
f=XYDataFromHistory(odb=odb,
outputVariableName=new_list[i],
steps=('Step-4', ), name='test{}'.format(i) )
results.append(f)
Error
Traceback (most recent call last):
File "odb_processing_SSD_acceleration_export_v4.py", line 66, in <module>
main()
File "odb_processing_SSD_acceleration_export_v4.py", line 32, in main
f=XYDataFromHistory(odb=odb,
NameError: global name 'XYDataFromHistory' is not defined
I am trying to run a simple example using sbmltoodepy and I am receiving the following error.
Traceback (most recent call last):
File "C:\Users\AppData\Roaming\JetBrains\PyCharm2021.2\scratches\scratch_79.py", line 8, in
ParseAndCreateModel(inputFilePath)#, jsonFilePath=None, outputFilePath=None)#, className="SBMLmodel")
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\sbmltoodepy\utilities.py", line 66, in ParseAndCreateModel
modelData = ParseSBMLFile(inputFilePath)
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\sbmltoodepy\parse.py", line 284, in ParseSBMLFile
assert(doc.getNumErrors() == 0)
AssertionError
Here is the code that I used.
import sbmltoodepy
from sbmltoodepy import ParseAndCreateModel
inputFilePath = "E:/Borisov2009_insulin_EGF.xml"
ParseAndCreateModel(inputFilePath, jsonFilePath=None, outputFilePath=None, className="SBMLmodel")
model = sbmltoodepy.SBMLmodel()
model.RunSimulation(1, absoluteTolerance = 1e-12, relativeTolerance = 1e-6)
Thank you in advance for your time.
I'm trying to select a DC with a HBITMAP, but I seem to get an error. I'm using Pywin32 for Win32 functions as well as ctypes for the VirtualAlloc function.
data = VirtualAlloc(0, (x*y+x)*512,MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)
hbm = CreateBitmap(x,y,1,32,data)
SelectObject(hdcdc, hbm)
Here's the error that occours when the code is executed:
Traceback (most recent call last):
File "...", line 32, in <module>
SelectObject(hdcdc, hbm)
TypeError: The object is not a PyHANDLE object
Thanks for any help!
You should invoke CreateDCFromHandle to create a DC object then use it's SelectObject method.
dc_hwnd = win32gui.GetWindowDC(desk_hwnd)
desk_dc = win32ui.CreateDCFromHandle(dc_hwnd)
pen = win32ui.CreatePen(win32con.PS_SOLID, 10, win32api.RGB(255, 0, 0))
old_pen = desk_dc.SelectObject(pen)
from weka.clusterers import Clusterer
import weka.core.converters as converters
data = converters.load_any_file("/home/ubuntu/test.csv")
data.class_is_last()
clusterer = Clusterer(classname="weka.clusterers.SimpleKMeans", options=["-N", "3"])
clusterer.build_clusterer(data)
print(clusterer)
# cluster the data
for inst in data:
cl = clusterer.cluster_instance(inst) # 0-based cluster index
dist = clusterer.distribution_for_instance(inst) # cluster membership distribution
print("cluster=" + str(cl) + ", distribution=" + str(dist))
I used the above code for doing k means custering i am not able to execute the program
The following are the errors I get
Traceback (most recent call last):
File "clus.py", line 6, in <module>
data = converters.load_any_file("/home/ubuntu/hello.csv")
File "/usr/local/lib/python2.7/dist-packages/weka/core/converters.py", line 255, in load_any_file
loader = loader_for_file(filename)
File "/usr/local/lib/python2.7/dist-packages/weka/core/converters.py", line 239, in loader_for_file
"(Ljava/lang/String;)Lweka/core/converters/AbstractFileLoader;", filename)
File "/usr/local/lib/python2.7/dist-packages/javabridge/jutil.py", line 932, in static_call
fn = make_static_call(class_name, method_name, sig)
File "/usr/local/lib/python2.7/dist-packages/javabridge/jutil.py", line 903, in make_static_call
klass = env.find_class(class_name)
AttributeError: 'NoneType' object has no attribute 'find_class'
I don't know why I am getting these errors. Can someone help me with this?
As described in the python-weka-wrapper API you have to import and start the Java Virtual Machine:
import weka.core.jvm as jvm
jvm.start()
It should solve your problem.
I am using three different ways to import Plot function. All fail.
1:
from sympy import *
if __name__ == '__main__':
pp1,pp2,el1,el2=insline(0,0,4,0,1.5,1,1.5,1)
print pp1.evalf(),pp2.evalf()
p=Plot()
p[0]=el1
p[1]=el2
p[2]=Segment(pp1,pp2)
p.show()
Shows:
Traceback (most recent call last):
File "C:\Users\Erdong\workspace\Gungeo\src\gungeo.py", line 39, in <module>
p=Plot()
NameError: name 'Plot' is not defined
2:
from sympy import Point, Ellipse, intersection, Segment,plot
import math
def
...
if __name__ == '__main__':
pp1,pp2,el1,el2=insline(0,0,4,0,1.5,1,1.5,1)
print pp1.evalf(),pp2.evalf()
p=plot.Plot()
p[0]=el1
p[1]=el2
p[2]=Segment(pp1,pp2)
p.show()
Shows:
Traceback (most recent call last):
File "C:\Users\Erdong\workspace\Gungeo\src\gungeo.py", line 39, in <module>
p=plot.Plot()
AttributeError: 'function' object has no attribute 'Plot'
3.
from sympy import Plot
Shows:
Traceback (most recent call last):
File "E:\Project\Build up\programming\learn\learn.py", line 7, in <module>
from sympy import Plot
ImportError: cannot import name Plot
Please help how to import Plot from sympy-0.7.6.
I also tried:
from sympy.plotting.pygletplot import PygletPlot as Plot
But got error also:
{
Traceback (most recent call last):
File "C:\Users\Erdong\workspace\Gungeo\src\gungeo.py", line 92, in
p=Plot(el1)
File "C:\Python27\lib\site-packages\sympy\plotting\pygletplot__init__.py", line 139, in PygletPlot
import plot
File "C:\Python27\lib\site-packages\sympy\plotting\pygletplot\plot.py", line 16, in
from plot_axes import PlotAxes
File "C:\Python27\lib\site-packages\sympy\plotting\pygletplot\plot_axes.py", line 7, in
from util import strided_range, billboard_matrix
File "C:\Python27\lib\site-packages\sympy\plotting\pygletplot\util.py", line 8, in
def get_model_matrix(array_type=c_float, glGetMethod=glGetFloatv):
NameError: name 'c_float' is not defined
}
Have a look at http://docs.sympy.org/latest/modules/plotting.html. It should be
from sympy import symbols
from sympy.plotting import plot
x = symbols('x')
p = plot(x)
Maybe you want the old Plot that uses pyglet:
from sympy.plotting.pygletplot import PygletPlot as Plot