Forum

Author Topic: Cannot import Metashape in python [No license found.]  (Read 8227 times)

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Cannot import Metashape in python [No license found.]
« on: March 25, 2019, 02:22:10 PM »
Dear Agisoft support team,

I started Metashape pro 30-day trial.
I successfully installed both gui and command line tools(Please see attached images).

However I'm not able to import Metashape in python.
It gives the message "No license found. Details: No license for product (-1)"

It is not possible to use command line tool as a trial user?
I hope to test script functionality before purchase.

Environment: macOS High Sierra 10.13.6

Many thanks

Best regards
kaz
« Last Edit: March 25, 2019, 02:41:33 PM by ktak199 »

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #1 on: March 25, 2019, 03:18:25 PM »
The command "print(Metashape.__path__)" returned the corrent path.
I successfully imported Metashape, although I received the message "No license found."

Thanks,

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #2 on: March 25, 2019, 04:56:19 PM »
Hello kaz,

Have you activate the GUI version using a trial license key on the same computer already?
Best regards,
Alexey Pasumansky,
Agisoft LLC

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #3 on: March 25, 2019, 05:20:28 PM »
Hello Alexey,
Thank you for your reply.

I think I successfully activated GUI version.
Please check attached images on the first post.
I selected the trial mode when I started for the first time.

Best regard,
kaz

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #4 on: March 25, 2019, 06:26:32 PM »
Additional information:

Code: [Select]
>>>import Metashape
>>>print(Metashape.app.activated)
False
>>>doc = Metashape.app.document
>>>print(doc)
None
>>>doc = Metashape.Document()
>>>print(doc)
<Document ''>
>>>doc.save()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-8-b188bfd64a3d> in <module>
----> 1 doc.save()

OSError: Document.save(): saving is disabled

Best regards,
kaz

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #5 on: March 26, 2019, 12:47:15 AM »
Additional information:

Please see attached image.
It looks activated as trial mode.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #6 on: March 26, 2019, 02:13:18 PM »
Hello kaz,

I can suggest to copy metashape.lic file from the application bundle contents (MetashapePro.app/Contents/MacOS/metashape.lic) to the Python module directory.

Or from Python IDLE console execute the following command with your trial key:
Code: [Select]
Metashape.License().acitvate("11111-22222-33333-44444-55555")
Best regards,
Alexey Pasumansky,
Agisoft LLC

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #7 on: March 26, 2019, 07:05:13 PM »
Hello Alexey,

Thank you for the reply.

I copied metashape.lic
because  I'm using trial version and don't know my trial key.

Metashape.app.activated became True.
However, I was not able to save model.
My current objective is to save model as like ply in script.
It should be posted as another topic?

Also, I seems strange that Metashape.app.document returns None.

Code: [Select]
>>> import Metashape
>>> print(Metashape.app.activated)
True
>>> doc = Metashape.app.document
>>> print(doc)
None
>>> doc = Metashape.Document()
>>> doc.open("test.psx")
>>> print(doc)
<Document 'path_to_file/test.psx'>
>>> chunk = doc.chunk
>>> chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True, reference_preselection=False)
>>> chunk.alignCameras()
>>> point_cloud = chunk.point_cloud
>>> print(point_cloud)
<PointCloud '12580 points'>
>>> print(chunk)
<Chunk 'Chunk 1'>
>>> chunk.exportModel("test.ply", binary=True, texture_format=Metashape.ImageFormatJPEG, texture=True, normals=False, colors=False, cameras=False, markers=False, format=Metashape.ModelFormatPLY)
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-9-38b20b4982fc> in <module>
----> 1 chunk.exportModel("test.ply", binary=True, texture_format=Metashape.ImageFormatJPEG, texture=True, normals=False, colors=False, cameras=False, markers=False, format=Metashape.ModelFormatPLY)

Exception: Null model

Best regards,
kaz
« Last Edit: March 26, 2019, 07:07:31 PM by kaz »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #8 on: March 26, 2019, 07:54:03 PM »
Hello kaz,

According to the script code, there's only point cloud in the chunk, but you are trying to export model (which assumes mesh model).

Metashape.app.document returns None since there's no active project. Use Metashape.Document() assignment instead to create a new project or open existing project.
Best regards,
Alexey Pasumansky,
Agisoft LLC

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #9 on: March 27, 2019, 04:04:39 AM »
Hello Alexey,

Thank you for your support.

I successfully exported points.

When I want to have dense point cloud as numpy array, it's the only way to save dense point cloud using exportPoints(for examaple, .ply format) function and import it as numpy array?
There is no way to convert directly from Metashape DenseCloud to numpy array?

Best regards,
kaz

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #10 on: March 27, 2019, 02:08:03 PM »
Hello kaz,

Currently it is not possible to convert dense cloud points internally to numpy array via Metashape Python API, so the only workaround seems to be exporting the cloud in plain text format and reading the file then.
Best regards,
Alexey Pasumansky,
Agisoft LLC

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Cannot import Metashape in python [No license found.]
« Reply #11 on: March 27, 2019, 04:21:34 PM »
Hello Alexey,

I understand and really appreciate your support!

Best regards,
kaz