C ++ cannot introduce the problem solution of the built-in module in calling the Python3 script.

Source: Internet
Author: User

C ++ cannot introduce the problem solution of the built-in module in calling the Python3 script.

C ++ cannot introduce the built-in module in the Python3 script to solve the problem. Recently I used tensorflow (the lazy version) to make some things. Due to python's performance, I used C ++ to collect data. Therefore, C ++ is required to call the python module. For the lazy version in windows, only 3.5 + can be used, otherwise there will be no such thing.

Problem: built-in modules cannot be introduced in the startup script.

Create

Create a simple File

By comparing whether numpy is introduced, we can find that it is indeed an error caused by the introduction of built-in modules.

Ps: PyErr_Print () in the qt environment; this function does not respond.

Cause: I guess the Python environment started from C ++ does not use environment variables when running the script (or does not scan the built-in modules at all), so the module path cannot be found. Solution: 1. Copy the built-in modules to the running directory.

2. import finds the built-in module through the absolute path

Note: from the test results, the module path cannot be found when the error is true.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.