Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:32:08+00:00 2026-06-02T08:32:08+00:00

I am working on a simple(?) embedded Python project. I have a custom package

  • 0

I am working on a simple(?) embedded Python project. I have a custom package that has been installed into site-packages with ‘setup.py install’, e.g.:

in C:\Python27\Lib\site-packages\:

mypackage\
    __init__.py
    subpackage\
        __init__.py
        subpackage.py
    .... 
    mymodule.py

Just doing some simple embedding calls, I am getting some behavior that doesn’t match what I get in a cmd window running Python. Specifically:

PyRun_SimpleString("import mypackage") //Success (return == 0)
PyRun_SimpleString("from mypackage import subpackage") //Success
PyRun_SimpleString("from mypackage import mymodule") //Fail (return == -1)

…whereas all of these work just fine in a cmd window (no ImportError, and I can get expected results on e.g. dir(mymodule)

I’m aware that the interpreter that results from Py_Initialize() is a little different from what you get in a cmd window, notably sys.path…having read some of the other answers on SO I tried inserting ” as the first element of sys.path:
PyRun_SimpleString("import sys\nsys.path.insert(0,'')") prior to the failing import, but no luck, still returns -1. Also tried appending sys.path with ‘C:\Python27\Lib\site-packages\mypackage’, but still no luck importing ‘mymodule’ (mymodule.py).

Based on other examples on SO and other sites, I’ve tried a few variants on import, e.g.

__import__('mypackage',globals(), locals(), fromlist=['mymodule'])
__import__('mypackage.mymodule',globals(), locals(), fromlist=['mymodule'])

Also tried PyImport_ImportModuleEx and as with PyRun_SimpleString, it worked for everything except “from mypackage import mymodule”.

Furthermore: this scenario works just fine under MacOS/Python 2.7. It’s just under Windows that it’s failing.

Any ideas where this could be going off the rails?

UPDATE: some additional information: ‘subpackage.py’ imports an extension library (let’s call it ‘utilites.pyd’). I’m able to import other “.py” modules that do not import this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:32:13+00:00Added an answer on June 2, 2026 at 8:32 am

    Taking the rare opportunity to answer my own question…

    Once I narrowed the problem down to modules that were importing the utilities.pyd extension, I did some digging around with the Dependency Walker tool and discovered that there was an error loading MSVCR90.DLL (file not found). In the old days, you could just drop that DLL into your application’s path and it would usually work.

    But nowadays (Vista and after), it’s a bit more involved. After reading this interesting blog post about an older MSVCR DLL, I figured I would try updating the <dependency> section of the manifest of my .pyd file to point to the same MSVCR90.DLL as Python27.DLL which resides in the \Windows\WinSxS (side-by-side) folder.

    After that, it worked like a charm. Now I just need to figure out how to automatically include the dependency section during python setup.py mypackage, but that’s another question 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a simple protocol stack for a small embedded system (multidrop,
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
im working on a simple C++ HTTP server as a school project and I
im working on a simple game like space invaders,and i got into a problem.
I am working on an user space app for an embedded Linux project using
I want to produce a simple, static HTML file, that has one or more
I am working on a project that is using an Oracle database with stored
We currently have a set of crystal reports used for winforms projects embedded into
I have a more complicated function that I am working on. I want to
I have a simple Vaadin portlet which displays an Embedded page e.g www.stackoverflow..com. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.