您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)polyscope庫(kù)如何在python 項(xiàng)目中進(jìn)行安裝,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
安裝就可以在環(huán)境配置好的情況下使用pip安裝:
pip install polyscope
如果提示找不到庫(kù)文件,no moudle的話可以試著把安裝下來(lái)的polyscope文件夾放在和想要運(yùn)行的py文件的同一目錄下。
而我們安裝下來(lái)的polyscope文件夾在哪里呢?它們應(yīng)該位于安裝目錄中的"Lib/site-packages"中,我的如下圖所示:
但是裝好之后我們運(yùn)行一個(gè)網(wǎng)上的例程:
import polyscope as ps # Initialize polyscope ps.init() ### Register a point cloud # `my_points` is a Nx3 numpy array ps.register_point_cloud("my points", my_points) ### Register a mesh # `verts` is a Nx3 numpy array of vertex positions # `faces` is a Fx3 array of indices, or a nested list ps.register_surface_mesh("my mesh", verts, faces, smooth_shade=True) # Add a scalar function and a vector function defined on the mesh # vertex_scalar is a length V numpy array of values # face_vectors is an Fx3 array of vectors per face ps.get_surface_mesh("my mesh").add_scalar_quantity("my_scalar", vertex_scalar, defined_on='vertices', cmap='blues') ps.get_surface_mesh("my mesh").add_vector_quantity("my_vector", face_vectors, defined_on='faces', color=(0.2, 0.5, 0.5)) # View the point cloud and mesh we just registered in the 3D UI ps.show()
還是有錯(cuò)誤,找不到polyscope_bindings,我的解決辦法是在這個(gè)目錄下面還應(yīng)該有一個(gè)這個(gè)文件:
把他的名字改成polyscope_bindings.pyd就可以解決,庫(kù)就可以跑通了。但是原例程因?yàn)闆](méi)有給數(shù)組所有還有邏輯錯(cuò)誤,隨便給幾個(gè)就可以運(yùn)行了:
import polyscope as ps import numpy as np # Initialize polyscope ps.init() ### Register a point cloud # `my_points` is a Nx3 numpy array my_points=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]]) ps.register_point_cloud("my points", my_points) ### Register a mesh # `verts` is a Nx3 numpy array of vertex positions # `faces` is a Fx3 array of indices, or a nested list verts=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]]) faces=np.array([[1,1,1],[1,2,3],[1,2,4],[2,4,3],[2,2,2]]) ps.register_surface_mesh("my mesh", verts, faces, smooth_shade=True) # Add a scalar function and a vector function defined on the mesh # vertex_scalar is a length V numpy array of values # face_vectors is an Fx3 array of vectors per face vertex_scalar = np.array([1,2,3,4,5]) face_vectors=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]]) ps.get_surface_mesh("my mesh").add_scalar_quantity("my_scalar", vertex_scalar, defined_on='vertices', cmap='blues') ps.get_surface_mesh("my mesh").add_vector_quantity("my_vector", face_vectors, defined_on='faces', color=(0.2, 0.5, 0.5)) # View the point cloud and mesh we just registered in the 3D UI ps.show()
這就可以成功使用了
看完上述內(nèi)容,你們對(duì)polyscope庫(kù)如何在python 項(xiàng)目中進(jìn)行安裝有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。