I am a bit of a newbie to the command line. I used to have IPython (with all dependencies configured) on my last MacBook, such that I could click on an icon from the dash to launch iPython qtconsole (outside of terminal shell).
Now, on my new MacBook Pro, after installing all of the same files and dependencies, I am getting:
Jacobs-MacBook-Pro:~ Jacob$ ipython qtconsole
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
load_entry_point('ipython==1.0.dev', 'console_scripts', 'ipython')()
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 390, in launch_new_instance
app.initialize()
File "<string>", line 2, in initialize
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 315, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/core/application.py", line 323, in initialize
self.parse_command_line(argv)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 310, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 429, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 361, in initialize_subcommand
subapp = import_item(subapp)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/utils/importstring.py", line 40, in import_item
module = __import__(package,fromlist=[obj])
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/qt/console/qtconsoleapp.py", line 56, in <module>
from IPython.external.qt import QtCore, QtGui
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt.py", line 23, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt_loaders.py", line 241, in load_qt
result = loaders[api]()
File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt_loaders.py", line 171, in import_pyqt4
from PyQt4 import QtGui, QtCore, QtSvg
ImportError: dlopen(/Library/Python/2.7/site-packages/PyQt4/QtGui.so, 2): Library not loaded: /usr/local/lib/QtGui.framework/Versions/4/QtGui
Referenced from: /Library/Python/2.7/site-packages/PyQt4/QtGui.so
Reason: image not found
and, again being a newbie, I think part of the problem may rely on the output, here:
Jacobs-MacBook-Pro:~ Jacob$ brew install qt
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Warning: qt-4.8.4 already installed, it's just not linked
Thanks in an advance for any tips. And if you need me to run any command (to view more outputs) just let me know!
So, you have multiple Python installations, and aren't sure which one you have.
You have both Homebrew and MacPorts.
Your MacPorts is broken and you don't know how to fix it.
Fixing each of these may not be that hard, but I think it's time to wipe the slate clean and start over.
The "easy" way to do this is to reinstall the OS, using the standard backup-and-migrate stuff to preserve your Aqua-level apps, user preferences, documents, etc. But that's pretty drastic, and shouldn't be necessary.
To clean things up manually, first:
Uninstall MacPorts.
brew uninstall $(brew list). This removes all Homebrew packages. You could just unlink instead of uninstall, but you really want to rebuild them once your machine is cleaned up.
sudo rm -rf /Library/Python /Library/Frameworks/Python.framework /usr/local/share/python*. This wipes out most third-party Python installations. And if you don't know where yours came from, it's really the best you can do.
Take a look at whatever's left in /usr/local/bin. All kinds of stuff can end up here, from scripts installed with Apple's Python to the command-line tools for GUI apps like TextMate, Aquamacs, or GitHub to the tools that come with binary installs of SDL or Qt, so you may not want to just wipe out the whole thing—but you do want to look it all over. Also look at /usr/local/lib and /Library/Frameworks.
You also may need to edit your ~/.profile, etc. files to undo changes you or those installers may have made, like adding /opt/local/bin or /Library/Frameworks/Python.framework/Versions/2.7/bin to your PATH. There could also be changes in /etc, but that's less likely (and less likely to cause problems).
Now run brew doctor to make sure Homebrew is happy, reinstall any non-Python-related Homebrew packages and binary installers you want, and now you're ready to install/configure your python, PyQt4-or-PySide, iPython, etc. properly and live happily every after (until you buy a new computer next year).
Related
If found some hits on stackoverflow where people have issues using ete3 tools when PyQT4 is not installed, and this (used to) also apply for me. However, I've now tried to reinstall a piece of software and it keeps complaining about 'Module' has no attritube 'Treestyle'.
To test whether PyQT was installed, I ran this python script:
from PyQt4.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
Which prints:
('PyQt version:', '4.12.1')
I get this (common) error:
Traceback (most recent call last):
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1820, in <module>
sys.exit(main())
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1793, in main
args.start(args)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 408, in start_evo_sim
result = init_and_simulate(simu, intermediate_load_file, _options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 117, in wrapper
raise ex_type(message)
AttributeError: 'module' object has no attribute 'TreeStyle' (in subprocess)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 91, in process_func
ret = func(*args, **kwargs)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 295, in init_and_simulate
sim = sim_mod.create_simulation(**options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1940, in create_simulation
sim = ODE_simulation(params_dict)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1342, in __init__
super(ODE_simulation, self).__init__(params)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 86, in __init__
self.init_graphs()
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 795, in init_graphs
show=show, clean=clean, create=create)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1188, in __init__
self.init_phylo_tree_graph(clean=clean)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1219, in init_phylo_tree_graph
show=show, attribute_dict=self.attribute_mapper, create=clean, **kwargs)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 985, in __init__
self.init_tree_style_dict() # NOTE: unordered ok
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1110, in init_tree_style_dict
branch_vertical_margin=branch_vertical_margin)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1083, in make_tree_style
ts = ete3.TreeStyle()
Note: this time arround I am trying to install it on Ubuntu for Windows, but up till now almost everything that ran on Linux ran on this one too. It might be relevent though.
Any ideas?
PS To reproduce the problem, follow the following steps:
$ sudo apt-get install python-qt4
$ virtualenv ~/mypy --system-site-packages
$ source ~/mypy/bin/activate
$ (mypy) > pip install VirtualMicrobes
$ (mypy) > virtualmicrobes evo --name TestMicrobes >> error
PPS User eyllanesc confirmed this is an 'Ubuntu for Windows' problem. I'm still trying to fix it though, if anyone can help me figure out how to link the pyqt4 packages correctly to my virtualenv that would be great. I've tried linken the native one with ln -s but I'm not getting any further
I had similar issues. The problem might be that you don't have all the depencies installed and ete3 is not telling you all of them.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
Run it and it will tell you which dependencies are missing. Note that you might need to run it multiple times before you install them all!
Windows 10, Python 3.5, PyQt5 is installed via Pip, pyinstaller 3.2.1 also installed via Pip. I can make a little PyQt5 qml app that works fine when run normally under Python.
If I have a Python module called test.py that contains:
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView
and do:
pyinstaller main.py
I get:
3452 ERROR: Could not find qmake version 5.x, make sure PATH is set correctly or try setting QT5DIR.
3452 ERROR: Cannot find QT_INSTALL_QML directory, "qmake -query QT_INSTALL_QML" returned nothing
followed by:
Traceback (most recent call last):
File "C:\Python35\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
File "c:\python35\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python35\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
self.__postinit__()
File "c:\python35\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
self.assemble()
File "c:\python35\lib\site-packages\PyInstaller\building\build_main.py", line 470, in assemble
module_hook.post_graph()
File "c:\python35\lib\site-packages\PyInstaller\building\imphook.py", line 409, in post_graph
self._load_hook_module()
File "c:\python35\lib\site-packages\PyInstaller\building\imphook.py", line 390, in _load_hook_module
attr_value = sanitizer_func(attr_value)
File "c:\python35\lib\site-packages\PyInstaller\building\utils.py", line 466, in format_binaries_and_datas
src_root_path_or_glob))
FileNotFoundError: Path or glob "Qt" not found or matches no files.
If I comment out the second line from test.py (the one about QtQuick) PyInstaller succeeds.
I can't make the path point to qmake because I don't have qmake on my machine. I don't really understand why I need qmake?
With Python 3.4.4 and PyQt5 5.5.1 (from https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.5.1/ - I think this is the last PyQt5 for 3.4) and PyInstaller 3.2.1 this all works fine out of the box.
The difference I think is that the PyQt5 directory structure under Lib\site-packages\PyQt5 is very different between 3.4 and 3.5 and I guess PyInstaller isn't coping with that yet. In particular, Python34 has the Qt5 binaries (Qt5Core.dll etc) in the root of Lib\site-packages\PyQt5 whereas in Python35 they end up tucked away under Lib\site-packages\PyQt5\Qt\bin. There are a lot of other differences too.
Anyway, the easy answer is therefore use Python34 / PyQt5.5.1. FWIW I have sort of got it working with Python35 and latest PyQt5 (5.8.1), but it's a bodge. I have both Python34 and Python35 installed, and the following (in this order) in my Windows path:
C:\Python35\
C:\Python35\Scripts\
C:\Python35\Lib\site-packages\PyQt5\Qt\bin
C:\Python34\Lib\site-packages\PyQt5
The Python34 line has to be there otherwise we get the Could not find qmake version 5.x stuff, and the Python35\Lib\site-packages\PyQt5\Qt\bin path being above that seems to make it pick up the correct binaries.
Doing this, pyinstaller reports success, but when I run I get a failure about Cannot load library ... dist\main\qml\QtQuick\Controls\qtquickcontrolsplugin.dll: The specified procedure could not be found. This can be solved by manually copying over Python35\Lib\site-packages\PyQt5\Qt\qml\QtQuick\Controls\qtquickcontrolsplugin.dll to dist\main\qml\QtQuick\Controls. After that my app runs as expected.
I haven't found a way to make pyinstaller pick up the correct qtquickcontrolsplugin.dll automatically.
I guess leaving C:\Python34\Lib\site-packages\PyQt5 in the path it's probably picking up some other wrong files from Python34, and if that's the case you can copy them over manually or try to fiddle with paths etc. to try to make the right thing happen, but I'm just going to use Python34 until PyInstaller gets fixed.
I had the same issue as you.
But, today it's work with this patch: https://github.com/pyinstaller/pyinstaller/pull/3233#issuecomment-362094587
Context: I started using OSX about a year ago, and I had a kind of screwy python installation. That is, I was using system python, and installed packages with sudo when that seemed to make things work. Now, I'm starting from a fresh OSX install, and trying to do it the Right Way. I've installed python and python3 from brew, and trying to use python3 whenever possible.
Problem: I have a .pythonrc file, which just imports a handful of commonly used packages - mostly standard lib, a few popular nonstandard packages, and a few of my own. In the past, this file has only been run when I start an interactive shell. Now, when using brew python, it is run whenever I run any python program.
There must be some gap in my understanding of the rc file - I thought the purpose was specifically for interactive use. Still, when I use system python, the rc file isn't used - so something is different about my system python (2.7.10 at /usr/bin/python) vs brew python (2.7.12 at /usr/local/bin/python; 3.5.2 at /usr/local/bin/python3). The behavior is the same if I remove everything except a print statement from the rc file.
edit: I realized that the rc file is running because I'm importing ipdb. This makes sense I suppose, but I still don't understand why that would happen in some of the python environments/versions but not others.
edit: https://github.com/gotcha/ipdb/blob/master/ipdb/main.py#L44 this line fails, not sure if this means anything.
Full stacktrace from within .pythonrc:
File "hello.py", line 1, in <module>
from ipdb import set_trace
File "/usr/local/lib/python2.7/site-packages/ipdb/__init__.py", line 7, in <module>
from ipdb.__main__ import set_trace, post_mortem, pm, run # noqa
File "/usr/local/lib/python2.7/site-packages/ipdb/__main__.py", line 51, in <module>
ipapp.initialize([])
File "<decorator-gen-109>", line 2, in initialize
File "/usr/local/lib/python2.7/site-packages/traitlets/config/application.py", line 74, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 315, in initialize
self.init_code()
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 263, in init_code
self._run_startup_files()
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 342, in _run_startup_files
self._exec_file(python_startup)
File "/usr/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 328, in _exec_file
raise_exceptions=True)
File "/usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2469, in safe_execfile
self.compile if kw['shell_futures'] else None)
File "/usr/local/lib/python2.7/site-packages/IPython/utils/py3compat.py", line 288, in execfile
builtin_mod.execfile(filename, *where)
File "~/.pythonrc", line 57, in <module>
import traceback; traceback.print_stack()
You can ask the traceback module:
$ cat .pythonrc
import traceback; traceback.print_stack()
$ cat test.py
import ipdb
Then by running
$ PYTHONSTARTUP="$HOME/.pythonrc" python test.py
you should get a traceback that tells you exactly from where the startup script is being run. Most likely, this is due to a call
start_ipython()
somewhere in the ipdb import.
I installed cocos2d today on OS X Lion, but whenever I try to import cocos in the Python interpreter, I get a bunch of import errors.
File "", line 1, in File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/cocos2d-0.5.0-py2.7.egg/cocos/init.py",
line 105, in
import_all() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/cocos2d-0.5.0-py2.7.egg/cocos/init.py",
line 89, in import_all
import actions File "/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/cocos2d-0.5.0-py2.7.egg/cocos/actions/
init.py", line 37, in
from basegrid_actions import * File "/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/cocos2d-0.5.0-py2.7.egg/cocos/actions/
basegrid_actions.py", line 62, in
from pyglet.gl import * File "build/bdist.macosx-10.6-intel/egg/pyglet/gl/init.py", line 510,
in File
"build/bdist.macosx-10.6-intel/egg/pyglet/window/init.py", line
1669, in File
"build/bdist.macosx-10.6-intel/egg/pyglet/window/carbon/
init.py", line 69, in File "build/bdist.macosx-10.6-intel/egg/pyglet/lib.py", line 90, in
load_library File
"build/bdist.macosx-10.6-intel/egg/pyglet/lib.py", line 226, in
load_framework File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/ctypes/init.py", line 431, in LoadLibrary
return self._dlltype(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/ctypes/init.py", line 353, in init
self._handle = _dlopen(self._name, mode) OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/ QuickTime, 6):
no suitable image found. Did find:
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture
Since I can't fix it, I'd like to remove cocos2d entirely. The problem is that I can't seem to find a guide anywhere that details how to remove it from the Python installation.
Any help regarding either of these problems is greatly appreciated.
You could fix it.
The problem comes from the fact that cocos2D is built on top of Pyglet, and the stable release of pyglet does not yet support Mac OS X 64 bits architecture. You have to use the 1.2 release of pyglet or later, which by now is not released yet.
A workaround is to remove any existing Pyglet install:
pip uninstall piglet
Then install the latest Pyglet from the mercurial repository
pip install hg+https://pyglet.googlecode.com/hg/
I have Mercurial 1.8.1, Python 2.6.6 installed on Win 2k8 R2 running on a vm. I have tried installing from msi, source and using tortisehg. Command-line Hg works fine but I get the same error when running the hgweb.cgi:
Traceback (most recent call last):
File ".\hgweb.cgi", line 17, in
application = hgweb(config)
File "mercurial\hgweb\__init__.pyc", line 26, in hgweb
File "mercurial\hgweb\hgwebdir_mod.pyc", line 61, in __init__
File "mercurial\hgweb\hgwebdir_mod.pyc", line 70, in refresh
File "mercurial\ui.pyc", line 35, in __init__
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\util.pyc", line 576, in
File "mercurial\demandimport.pyc", line 85, in _demandimport
File "mercurial\windows.pyc", line 21, in
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\osutil.pyc", line 12, in
File "mercurial\osutil.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
The other answers I have found on SO and elsewhere pointed me to try installing from source, dropping the pure osutil into the install, or installing an older version. I have tried them all.
This is especially frustrating because I have other, similar non-vm machines running fine but have been unable to find the disconnect.
Ideas?
I had the same error using following system configuration
Python-2.6.6 installed as msi
mercurial-1.8.2-x86 installed as msi
IIS7
I solved this problem simply:
Python has been installed early
Uninstall Mercurial msi package
Download and install "Mercurial-1.8.2 (32-bit py2.6)" installer from mercurial website which is marked as "This is recommended for hgweb setups".
copyed content of C:\Python26\Lib\site-packages\mercurial\ to the directory used in IIS7 website setup.
Till now all is working. Hope this will help.
Whenever I have less than descriptive error messages that tell me something is going on at the system level but not what, I use Sysinternals' Procmon to tell me what's going with the registry and filesystem. It's verbose, and getting the filter to show just the process of interest takes some learning, but you can export the results to Excel and skim them for suspicious-looking results. Pay particular attention to failures, of course.
Give it a try and see what DLL is being searched for.