[MacPorts] #38560: port install opencv +python27 fails
#38560: port install opencv +python27 fails --------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Keywords: | Port: --------------------------+-------------------------------- sudo port selfupdate sudo port install python27 py27-numpy py27-scipy sudo port install opencv +python27 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/ then contains linkages for numpy and scipy but nothing for opencv so the linkage doesn't work. ......... I'm told that this fixes the problem with Homebrew: cv2.so and cv.py are located in "/usr/local/Cellar/opencv/2.4.4a/lib/python2.7/site-packages" You need to copy those two files into the python site-packages directory which should be "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/" I'm also told that this fixes it with Windows: "Copy the file cv2.pyd and paste it into C:\Python27\Lib\site-packages." It is located in C:\Python27\Lib\site-packages\opencv\build\python\2.7 The Macports linkage seems too complex for a quick solution, but is there one? -- Ticket URL: <https://trac.macports.org/ticket/38560> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: | ---------------------------+-------------------------------- Changes (by larryv@…): * status: new => closed * resolution: => invalid Old description:
sudo port selfupdate sudo port install python27 py27-numpy py27-scipy sudo port install opencv +python27
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/
then contains linkages for numpy and scipy but nothing for opencv so the linkage doesn't work.
.........
I'm told that this fixes the problem with Homebrew: cv2.so and cv.py are located in "/usr/local/Cellar/opencv/2.4.4a/lib/python2.7/site-packages" You need to copy those two files into the python site-packages directory which should be "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/"
I'm also told that this fixes it with Windows: "Copy the file cv2.pyd and paste it into C:\Python27\Lib\site-packages." It is located in C:\Python27\Lib\site-packages\opencv\build\python\2.7
The Macports linkage seems too complex for a quick solution, but is there one?
New description: {{{ sudo port selfupdate sudo port install python27 py27-numpy py27-scipy sudo port install opencv +python27 }}} `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/` then contains linkages for numpy and scipy but nothing for opencv so the linkage doesn't work. ......... I'm told that this fixes the problem with Homebrew: cv2.so and cv.py are located in "/usr/local/Cellar/opencv/2.4.4a/lib/python2.7/site-packages" You need to copy those two files into the python site-packages directory which should be "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/" I'm also told that this fixes it with Windows: "Copy the file cv2.pyd and paste it into C:\Python27\Lib\site-packages." It is located in C:\Python27\Lib\site-packages\opencv\build\python\2.7 The Macports linkage seems too complex for a quick solution, but is there one? -- Comment: Replying to [ticket:38560 johnsankey@…]:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/
then contains linkages for numpy and scipy but nothing for opencv so the linkage doesn't work.
MacPorts does not install anything into `/Library`. If numpy and scipy are there, it is because you installed them yourself. MacPorts keeps Python 2.7 packages in `${prefix}/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /site-packages`.
The Macports linkage seems too complex for a quick solution, but is there one?
The solution (and only configuration we support) is to use MacPorts’ Python 2.7. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:4> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Changes (by larryv@…): * cc: testing1@… (removed) * port: => opencv -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:5> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…): Why doesn't the method I used get MacPort's Python 2.7? My understanding is that sudo port can only do that. I have never even heard of numpy or scipy before issuing the commands I list above... -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:6> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by larryv@…): `sudo port install python27` will get you MacPorts’ Python. What does `port contents py27-numpy` say? I just installed `py27-numpy` and everything is under `/opt/local`; see my attachment. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:7> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…):
What does `port contents py27-numpy` say? I just installed `py27-numpy` and everything is under `/opt/local`; see my attachment. Yes, everything is under /opt/local.
-- Ticket URL: <https://trac.macports.org/ticket/38560#comment:8> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by larryv@…): Replying to [comment:8 johnsankey@…]:
So it seems I'm getting Apple's Python with 'set python python27', not the MacPorts Python.
I assume you mean `port select`. `port set` is a shortcut for `port setrequested`. What is the output of `port select --list python`? Can you import the OpenCV module if you start the interpreter using `/opt/local/bin/python2.7`?
What directory is MacPorts' Python27 in? (I assume specifying directory in set will work.)
No, that is not how `port select` works.
BTW, I've been double-clicking on a .py file - it brings up Idle and then (Apple) python. Is any change needed in additional to specifying path in set for this to get Macports' python27?
I don’t know which application is your default for `.py` files, but you can select a different `Build Applet.app` or `IDLE.app` or `Python Launcher.app` through Finder’s Get Info panel, as usual. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:9> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…): Replying to [comment:9 larryv@…]:
Replying to [comment:8 johnsankey@…]:
So it seems I'm getting Apple's Python with 'set python python27', not the MacPorts Python.
I assume you mean `port select`. `port set` is a shortcut for `port setrequested`. What is the output of `port select --list python`?
No. I mean "set python python27" issued at the command prompt, which is what I was told to do in the installation instructions for opencv. I've never heard of "port select".
Can you import the OpenCV module if you start the interpreter using
`/opt/local/bin/python2.7`? No, I get the same Apple python as before, and import opencv fails as it did before. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:10> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by larryv@…): Replying to [comment:10 johnsankey@…]:
No. I meant "set python python27" issued at the command prompt, which is what I was told to do in the installation instructions for opencv.
I can only conclude that those instructions were wrong. For me, `port set` does not do the same thing as `port select --set`.
Can you import the OpenCV module if you start the interpreter using `/opt/local/bin/python2.7`?
No, I get the same Apple python as before, and import opencv fails as it did before.
What do these commands output? {{{ which python ls -l /opt/local/bin/python{,2.7} }}}
My Finder info window says default for .py is idle, but it doesn't give me the option of which idle, it just gives me the one linked to the Apple python.
Do you have an `/Applications/MacPorts/Python 2.7` folder? What’s in it? -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:11> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: invalid | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…): Replying to [comment:11 larryv@…]:
I can only conclude that those instructions were wrong. For me, `port set` does not do the same thing as `port select --set`. Fair enough - I've forwarded your comment to the web page author.
What do these commands output? which python ls -l /opt/local/bin/python{,2.7}
unknown-c8-2a-14-0e-69-42:~ john$ which python /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python unknown-c8-2a-14-0e-69-42:~ john$ ls -l /opt/local/bin/python{,2.7} lrwxr-xr-x 1 root admin 24 28 Mar 08:13 /opt/local/bin/python -> /opt/local/bin/python2.7 lrwxr-xr-x 1 root admin 73 28 Mar 04:59 /opt/local/bin/python2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 unknown-c8-2a-14-0e-69-42:~ john$
Do you have an `/Applications/MacPorts/Python 2.7` folder? What’s in it?
/Applications/MacPorts/Python 2.7 contents: Build Applet.app 2011-07-29 360 KB IDLE.app 2011-07-29 393 KB Python Launcher.app 2011-07-29 582 KB -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:12> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: port install opencv +python27 fails ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: reopened Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+-------------------------------- Changes (by larryv@…): * status: closed => reopened * resolution: invalid => Comment: We should probably bring in the maintainer. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:13> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Changes (by larryv@…): * owner: macports-tickets@… => stromnov@… * status: reopened => new -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:14> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Comment (by johnsankey@…): Further to the above: I've found that typing python at the command line opens MacPorts python27 that has opencv attached. However, the idle in that framework (/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle) is an alias of Apple's idle; it only deals with Apple Python27 that doesn't have opencv attached. Can I persuade MacPorts to install its own idle in this framework? Hopefully, MacPorts idle will deal with MacPorts python27, then I should be able to associate MacPorts idle with .py and use it that way. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:15> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Comment (by larryv@…): Replying to [comment:15 johnsankey@…]:
Further to the above: I've found that typing python at the command line opens MacPorts python27 that has opencv attached. However, the idle in that framework (/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle) is an alias of Apple's idle; it only deals with Apple Python27 that doesn't have opencv attached.
I don’t know what to make of this. Your setup sounds really broken. This what I see: {{{ % port -v installed python27 The following ports are currently installed: python27 @2.7.3_1 (active) platform='darwin 12' archs='x86_64' % ls -l /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle lrwxr-xr-x 1 root wheel 5B Nov 17 22:55 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle@ -> idle2 % ls -l /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle2 lrwxr-xr-x 1 root wheel 7B Nov 17 22:55 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle2@ -> idle2.7 % ls -l /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7 -rwxr-xr-x 1 root wheel 148B Nov 17 22:55 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7* % cat /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/idle2.7 #!/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 from idlelib.PyShell import main if __name__ == '__main__': main() % }}} -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:16> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Comment (by johnsankey@…): Sorry - should have added that the last above was after changing PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" in .profile to PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" At least it gets me the python with opencv installed. port -v installed python27 The following ports are currently installed: python27 @2.7.3_1+universal (active) platform='darwin 10' archs='i386 x86_64' Nothing about idle. I've found others who have similar problems with QGIS installed, but others who haven't who are also having problems getting opencv to work. (This is in a Coursera class forum, which only members can see.) Total PATH is now: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin PYTHONPATH is null... -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:17> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Comment (by larryv@…): Can you rebuild Python 2.7 and see if `idle` is still an alias? {{{ sudo port -n upgrade --force python27 }}} Also you don’t have to add that framework directory to your PATH if you want MacPorts’ Python to be the default when you run `python`. Use `port select`. {{{ sudo port select --set python python27 }}} -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:18> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+------------------------ Reporter: johnsankey@… | Owner: stromnov@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+------------------------ Comment (by johnsankey@…): Port select is a separate issue - I've already been down that route: it gets the first python27 in PATH. In order to use the MacPorts python, its location has to be before the Apple python location in PATH. This will be about the 4th time I've rebuilt python if I do :-( Might part of this be a conflict with WINE, which also imports and uses python? It's the only other MacPorts thing I've got in my system, and I'll bet it doesn't use Idle. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:19> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+-------------------------------- Changes (by larryv@…): * cc: jwa@… (added) * owner: stromnov@… => macports-tickets@… Comment: Replying to [comment:19 johnsankey@…]:
Port select is a separate issue - I've already been down that route: it gets the first python27 in PATH.
No, it gets MacPorts’ Python 2.7. PATH has nothing to do with it. Of course, all `port select` does is create a symlink at `/opt/local/bin/python` (assuming the default MacPorts prefix). As usual, your PATH has to be set up properly to catch it.
This will be about the 4th time I've rebuilt python if I do :-(
I can only conclude that your setup is broken. Try posting to the [[MailingLists|macports-users]] mailing list; maybe someone there can provide some insight. If not, then you might try [http://guide.macports.org/chunked/installing.macports.uninstalling.html reinstalling MacPorts].
Might part of this be a conflict with MacPorts WINE, which also imports and uses python? It's the only other MacPorts thing I've got in my system, and I'll bet it doesn't use Idle.
`wine` doesn’t touch `python27`. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:20> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…): When I issued sudo port select --set python python27 *on my system* it got Apple's python until I put the MacPorts python path ahead of the Apple python path, as described above. When I installed wine *on my system* with MacPorts, it installed MacPorts python at the same time as a dependency. I have already uninstalled MacPorts *on my system* and everything in it, then re-installed from scratch. Nothing was changed as a result. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:21> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by larryv@…): Replying to [comment:21 johnsankey@…]:
When I issued sudo port select --set python python27 *on my system* it got Apple's python until I put the MacPorts python path ahead of the Apple python path, as described above.
I don’t know what to say about that. I tried reproducing by reshuffling my $PATH before using `port select`, and it symlinks correctly.
When I installed wine *on my system* with MacPorts, it installed MacPorts python at the same time as a dependency.
Yes, that’s expected. What I mean is that the `wine` port does not alter the files installed by the `python27` port.
I have already uninstalled MacPorts *on my system* and everything in it, then re-installed from scratch. Nothing was changed as a result.
Well then maybe you should post to the mailing list, as I’ve already suggested. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:22> MacPorts <http://www.macports.org/> Ports system for OS X
#38560: opencv +python27: cannot import Python module ---------------------------+-------------------------------- Reporter: johnsankey@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: opencv | ---------------------------+-------------------------------- Comment (by johnsankey@…): The consensus seems to be that it was the python site Python 2.7 in /Library that was taking over the system from MacPorts. I cleaned it out, reinstalled OSX+X11 to ensure that all Apple pythons are sound (they seem to be), deleted /opt, then reinstalled everything MacPorts from scratch. Now, MacPorts stuff now seems to be properly installed. However, MacPorts IDLE doesn't work, so I've submitted a new ticket for that: #38746. -- Ticket URL: <https://trac.macports.org/ticket/38560#comment:23> MacPorts <http://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts