Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name windll on Macos X #80

Closed
sebma opened this issue Jul 7, 2017 · 26 comments
Closed

ImportError: cannot import name windll on Macos X #80

sebma opened this issue Jul 7, 2017 · 26 comments

Comments

@sebma
Copy link

sebma commented Jul 7, 2017

Hi,

I have installed Picoscope Beta v6.11.13.2 (the drivers are included)

I'm using Macos X 10.12.5 and when I try to :

ps = ps2000.PS2000(), I get this error :

In [3]: ps = ps2000.PS2000()
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-3eb67f4a7698> in <module>()
----> 1 ps = ps2000.PS2000()

/usr/local/lib/python2.7/site-packages/picoscope/ps2000.pyc in __init__(self, serialNumber, connect)
    128             self.lib = cdll.LoadLibrary("lib" + self.LIBNAME + ".so")
    129         else:
--> 130             from ctypes import windll
    131             self.lib = windll.LoadLibrary(self.LIBNAME + ".dll")
    132

ImportError: cannot import name windll

Can you help me ?

@sebma sebma changed the title ImportError: cannot import name windll on Macos X ImportError: cannot import name windll on Macos X Jul 7, 2017
@hmaarrfk
Copy link
Collaborator

hmaarrfk commented Jul 7, 2017 via email

@hmaarrfk hmaarrfk changed the title ImportError: cannot import name windll on Macos X Macos X Support Jul 7, 2017
@sebma
Copy link
Author

sebma commented Jul 8, 2017

Hi, cannot do it today because I'm at home and I don't have an ssh to it but.

But I have an ssh access to an older one (Mac OS X 10.11.6) and platform.system() says :

'Darwin'

I've already seen this name and I'm almost positive that the mac I use at the university will also answer ''Darwin', therefore you can already start testing if platform.system() == 'Darwin' :-)

@hmaarrfk
Copy link
Collaborator

hmaarrfk commented Jul 8, 2017

Ok you are going to have to test things for us.

I assume you know how to use git?
If you have installed our library through pip, please remove it

pip uninstall picoscope

Checkout the mac branch of our library

git clone [email protected]:colinoflynn/pico-python.git
git checkout mac

install the picoscope library in development mode using the mac branch:

python setup.py develop

You can see the difference between the mac branch and the master branch in this commit, I'll pull it in if you say that it works.

83a5ac3

@sebma
Copy link
Author

sebma commented Jul 10, 2017

Hi, I'm back at work :)

git clone [email protected]:colinoflynn/pico-python.git says :

Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@colinoflynn
Copy link
Owner

It should be

      git clone https://github.com/colinoflynn/pico-python.git

The ssh URL requires you to have repo access.

@sebma
Copy link
Author

sebma commented Jul 10, 2017

Ok I had to cd pico-python before doing the git checkout mac

Now I just installed the picoscope library in development mode.

And when I run ps = ps2000.PS2000(), It now says :

In [2]: ps = ps2000.PS2000()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-2-3eb67f4a7698> in <module>()
----> 1 ps = ps2000.PS2000()

/Users/mansfeld/src/pico-python/picoscope/ps2000.py in __init__(self, serialNumber, connect)
    126         if platform.system() == 'Linux' or platform.system() == 'Darwin':
    127             from ctypes import cdll
--> 128             self.lib = cdll.LoadLibrary("lib" + self.LIBNAME + ".so")
    129         else:
    130             from ctypes import windll

/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.pyc in LoadLibrary(self, name)
    438
    439     def LoadLibrary(self, name):
--> 440         return self._dlltype(name)
    441
    442 cdll = LibraryLoader(CDLL)

/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.pyc in __init__(self, name, mode, handle, use_errno, use_last_error)
    360
    361         if handle is None:
--> 362             self._handle = _dlopen(self._name, mode)
    363         else:
    364             self._handle = handle

OSError: dlopen(libps2000.so, 6): image not found

By searching libps2000.*, I found this file :

/Applications/PicoScope6.app/Contents/Resources/lib/libps2000.dylib

@sebma
Copy link
Author

sebma commented Jul 10, 2017

@hmaarrfk @colinoflynn I believe, maybe in ps2000.py#L126, you can try this :

        if platform.system() == 'Linux' :
            from ctypes import cdll
            self.lib = cdll.LoadLibrary("lib" + self.LIBNAME + ".so")
        elif platform.system() == 'Darwin' :
            from ctypes import cdll
            self.lib = cdll.LoadLibrary("lib" + self.LIBNAME + ".dylib")
        else:
            from ctypes import windll
            self.lib = windll.LoadLibrary(self.LIBNAME + ".dll")

But then it says OSError: dlopen(libps2000.dylib, 6): image not found because the computer doesn't know where to find it.

@sebma
Copy link
Author

sebma commented Jul 10, 2017

Ok, I found how :

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Applications/PicoScope6.app/Contents/Resources/lib

and then run ipython

@hmaarrfk
Copy link
Collaborator

Hi sebma,

I assume that the two changes you did were to

  1. use the extension .dylib
  2. exporting the path

Did picoscope teach you about exporting the path? Do you have a reference for this? I would rather not duplicate install instructions that are available on the official picotech website.

Other than that, I'll try to update the libraries we have to enable Mac support.

Mark

@sebma
Copy link
Author

sebma commented Jul 10, 2017

Did picoscope teach you about exporting the path? Do you have a reference for this? I would rather not duplicate install instructions that are available on the official picotech website.

I don't understand what you mean because I don't think you need to change your install instructions at all.

Maybe if you are willing, just give a little advice in a new README.Macos file regarding the LD_LIBRARY_PATH variable :)

Thank you for your time and patience.

Please me, keep me updated when you have .dylib extension support in your picoscope libraries.

@hmaarrfk
Copy link
Collaborator

You didn't simply guess that you had to add this specific path:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Applications/PicoScope6.app/Contents/Resources/lib

Was this your knowledge of software, or some instructions on the picotech website?

@sebma
Copy link
Author

sebma commented Jul 10, 2017

Ok, now I understand the question :) and the answer is :

$ find /Applications -name "libps2000.*"
/Applications/PicoScope6.app/Contents/Resources/lib/libps2000.2.dylib
/Applications/PicoScope6.app/Contents/Resources/lib/libps2000.dylib

@sebma
Copy link
Author

sebma commented Jul 10, 2017

It's almost 8pm, so I really have to go :)

Jesus bless you !

@hmaarrfk
Copy link
Collaborator

Ah ok, so you hunted for the library yourself.

I'll try to push it to pip soon.

BTW, this is about as much as I can do in terms of helping you setup the MacOSX libraries.

If you want to continue fixing things up, I suggest you do the following:

  1. Fork our library
  2. Make a new branch in your version of the repository
  3. Make changes
  4. Issue a pull request once you think you've ironed out the bugs so that we can share it with the rest of the people.

@sebma
Copy link
Author

sebma commented Jul 11, 2017

@hmaarrfk Hi,

Unfortunatly, I don't have much time to do this at the moment because I'm already late in my tasks.

The only thing you need to do on your side is to modify from lines 126 to 131 of ps2000.py#L126-L131 using this piece of code.

Add then apply that to the other libraries as well.

Maybe replace this piece of code by a function that you can call.

@hmaarrfk
Copy link
Collaborator

The changes were done soon after you requested them in the mac branch. I didn't merge them into the main branch because I wanted time to review the changes. I think I'll push them in now.

@sebma
Copy link
Author

sebma commented Jul 13, 2017

@hmaarrfk Thanks a lot :)

@sebma
Copy link
Author

sebma commented Aug 10, 2017

@hmaarrfk
Hi, here are the two Macos X commands to add current USER to the picogroup :

# Create the new pico group :
sudo dseditgroup -o create pico
# Add the current user to the pico group :
sudo dseditgroup -o edit -a $USER -t user pico

It can be also done with a single command :)

sudo dseditgroup -o create -a $USER -t user pico

You can add the them in the Additional Installation Information for Mac OSX.

@hmaarrfk
Copy link
Collaborator

Thanks.

Please create a new issue that way we keep track of the things that we still have "todo"

Mark

@sebma
Copy link
Author

sebma commented Aug 11, 2017

@hmaarrfk Hi,

Why not reopen this one ? It's title seems fine to me to follow the "Macos X Support" changes.

@hmaarrfk
Copy link
Collaborator

Reopenning issues makes them difficult to track down. While there were only 10s of comments on this one, what happens when there are 100s?

If I hadn't seen this email immediately, I would have missed your comment since Closed Issues don't appear in the same list as open issues.

If you come by this thread 5 years later, after a few versions of MacOS X have been released, is the original issue mentioned still a problem? You would have to read about 10 different issues, just to see which one you care about, and to see if it was fixed.

Anyway, it isn't that big of a deal, and this one was borderline appropriate to reopen. I could have seen it as: "your previous instructions were incomplete". But I can also see it as not an issue with our library as the first issue required changes in the code, but rather the way you installed the picotech library on your own computer.

@sebma
Copy link
Author

sebma commented Aug 11, 2017

@hmaarrfk Ok, now I understand. Let me change the title of this issue and also create a new one.

@sebma sebma changed the title Macos X Support ps = ps2000.PS2000() : ImportError: cannot import name windll on Macos X Aug 11, 2017
@sebma
Copy link
Author

sebma commented Aug 11, 2017

@hmaarrfk What name can I choose for the new issue to keep track of the things that we still have "todo" ?

@sebma sebma changed the title ps = ps2000.PS2000() : ImportError: cannot import name windll on Macos X ImportError: cannot import name windll on Macos X Aug 11, 2017
@hmaarrfk
Copy link
Collaborator

Its fine, I fixed the Readme already.

Thanks for reporting bugs.

@sebma
Copy link
Author

sebma commented Aug 29, 2017

@hmaarrfk Hi,

My mistake on Macos, the name of variable containing the PATH to the libraries is not LD_LIBRARY_PATH but DYLD_LIBRARY_PATH.

Can you please change it in the README.md ?

@hmaarrfk
Copy link
Collaborator

Will do.

Please stop adding comments to this thread. Anything that needs a "fix" needs to be filed under a different change.

Repository owner locked and limited conversation to collaborators Aug 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants