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 8743385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:40:00+00:00 2026-06-13T11:40:00+00:00

I’m trying to port my application to Mac, but I don’t understand what’s causing

  • 0

I’m trying to port my application to Mac, but I don’t understand what’s causing this problem.

At some point, I try to load a couple of C++ libraries provided by a third party, using ctypes’ LoadLibrary. For Windows, I have dlls, and for Mac, dylibs. Loading the dylibs gives an error too which I’m also trying to solve, but that shouldn’t be an issue here, because I do have a try/except block for exactly that.

try:
    self.log('Lib exists? %s: %s' % (libpath, os.path.exists(libpath)))       
    origdir = os.getcwd()
    os.chdir(os.path.dirname(libpath))
    self.lib = cdll.LoadLibrary(os.path.basename(libpath))
    os.chdir(origdir)
    self.log("Loaded Library!")
except Exception as e:
    self.log('Error importing Library! %s' % e)
    self.lib_loaded = False

Any problems are written to a log file. The thing is, it is appending to the log file that somehow works for the first call, but doesn’t work the second time it’s called in the above fragment, at
self.log('Error importing Library! %s' % e).

The log method is pretty obvious:

def log(self, text):
    if self.debug:
        print text
        with open('logfile.log', 'a') as w:
            w.write('%s\n' % text)   

On Windows, this works without problems. When the library is found, it loads, and when it isn’t found, I get the appropriate message printed and written to the log. But on Mac, I get the error

Lib exists? /usr/local/lib/path/to/Mylib: True
Error importing Library! dlopen(lib.dylib, 6): no suitable image found.  Did find:
    lib.dylib: mach-o, but wrong architecture
    /usr/local/lib/lib.dylib: mach-o, but wrong architecture
Traceback (most recent call last):
  File "myapp.py", line 987, in <module>
    foo = Foo(pyqtapp, splash)
  File "myapp.py", line 83, in __init__
    self.thelibLink = libLink.libLink(0.05, a, b)
  File "libLink.py", line 100, in __init__
    self.log('Error importing Library! %s' % e)
  File "libLink.py", line 326, in log
    with open(self.logfile, 'a') as w:
IOError: [Errno 13] Permission denied: 'logfile.log'

logfile.log has the permissions -rw-r--r-- and is owned by me, so this doesn’t make any sense to me. Moreover, after running the program, the logfile contains this:

==Log of date/time==
Lib exists? /usr/local/lib/path/to/Mylib: True

So somehow I do have the permission to append to the file when self.log is called for the first time. Any ideas how I can solve 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-13T11:40:01+00:00Added an answer on June 13, 2026 at 11:40 am

    You are opening the log file with a relative path, but you change directories just before the failure:

    os.chdir(os.path.dirname(libpath))
    

    Open the logfile with an absolute path instead, since you obviously cannot write in os.path.dirname(libpath).

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,

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.