I installed TkTreeCtrl 2.4.1 (written in c), as well as TkTreectrl 1.0 ( written in python), which wraps the original c library.
When I try to create any treectrl objects in Python, I get the error:
_tkinter.TclError: can't find package treectrl
I'm pretty new to Python, but I'd guess that the Python wrapper code can't find the c library.
When I installed TkTreeCtrl(c) it installed itself in '/usr/lib/treectrl2.4.1' as a .dylib file.
I've never used a .dylib before, but some googling told me to add the directory it was in to the environment variable 'DYLD_LIBRARY_PATH'.
I did that, but no luck. I'm not sure I'm even know what my problem is, so any help would be greatly appreciated!
I'm running Lion and Python 2.7. Python was installed using MacPorts.
For its Python ports, MacPorts currently builds and installs its own X11-based Tcl and Tk ports. It looks like you would need to be careful when building TkTreeCtrl to specify the correct locations to ./configure for the MacPorts provided Tcl, Tk, and X11 libraries and include files. See ./configure --help for the names of the options. You should find the libraries and include files under /opt/local/, the default install location for MacPorts files.
There may be an easier option, though. It appears that the ActiveTcl distributions for Tcl/Tk include TkTreeCtrl. If you use a Python that links with ActiveTcl, you would just need to install the Python TkTreectrl module, which is straightforward. On Lion, a free (though not open source) download of ActiveTcl 8.5 is available here which will automatically be used with the python.org 2.7.2 64-bit installer for OS X available here. ActiveState also has its own Python distribution for OS X. There's more information about some of the quirks of Python and Tcl/Tk on OS X here. Note that the ActiveTcl is a more native implementation on OS X; it is not X11-based.
Related
I cannot get autocomplete working for OpenCV (Python) on Windows.
According to Abid's instructions here, I pasted the cv2.pyd file in the C:\Python27\Lib\site-packages.
In the Python code, I import as follows:
import cv2.cv as cv
I have also installed numpy, and it created its own folder in site-packages unlike OpenCV (which I've pasted directly into site-packages).
With this setup, the code executes without any problems, even when OpenCV methods are called.
But I have not been able to get autocomplete to work. I have tried to get it to work on Sublime Text 2 (with SublimeCodeIntel) and PyCharm. In both IDEs, autocomplete works for the numpy import, but fails for the OpenCV import.
I'm using OpenCV 2.4.6, and Python 2.7 (32 bit).
Any possible solutions?
The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.
EDIT
OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading #CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:
from cv2.cv import *
The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013.
I've had the same issue with PyCharm when building a custom version of OpenCV on windows. Here is what I did to fix it:
OpenCV made a folder in Python site-packages like so:
opencv site-packages
So what you need to do is just add the python-3.9 folder to your interpreter.
File
Settings...
Python interpreter
Three dots icon next to your interpreter -> Show all...
Select your interpreter and click on the "Show paths for selected interpreter" icon
Add the folder inside the cv2 site-packages
Now import the cv2 module normally.
The best way to solve all the problems of OPENCV-PYTHON is by uninstalling it and reinstalling it.
Even I faced the same problem.
I fixed it by:
python -m pip uninstall Opencv-python
Then I reinstalled it by using a lower version. But unfortunately, I did not know the versions of opencv; So by using a small trick you can get it by running:
python -m pip install opencv-python==
and you will get an error similar to this:
ERROR: Could not find a version that satisfies the requirement opencv-python== (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64) ERROR: No matching distribution found for opencv-python==
Here you can see all the versions of opencv-python; choose any one (but not the latest as the error occurs due the latest version of opencv-python. install it by using:
pip install opencv-python==3.4.17.61 (You can choose your version, but this version solved the issue for me)
then enjoy your coding....
Even AUTO-COMPLETE error in opencv-python gets solved.
HAPPY CODING
I compiled the development version of Vim with both Python 2 and Python 3 support. The output of vim --version has +python/dyn and +python3/dyn in it. I ran the configure file with
g
./configure --enable-pythoninterp --enable-python3interp --with-python-config-dir=/usr/lib64/python2.7/config --with-python3-config-dir=/usr/lib64/python3.3/config --with-x --with-features=huge
However when I run :python import sys; print(sys.version) I get
E448: Could not load library function _PyArg_Parse_SizeT
E263: Sorry, this command is disabled, the Python library could not be loaded.
Why would this be? I found out because of YouCompleteMe stating that it requires Vim compiled with 2.x support.
Thanks
I had a similar issue on my Debian box. If you're using a Debian-based system, you will not be able to load both Python libraries simultaneously. That's why when you set --enable-python-interp and --enable-python3-interp they always load with the /dyn suffix.
If your vim plugins don't need both versions, you should just pick one of the versions and stick with it. The links below provide more info.
Explained by Debian maintainer
Vim Python Support
P.S. - In case you tried this on Windows as well, loading either Python version will work, so the /dyn isn't an issue there.
I am trying to install python with pygtk in my ubuntu system.
I don't have root access so I need to install all the packages locally say /home/user/local/lib
I am able to install python, but I am not able to link other packages(pygobject, pygtk, etc) to the locally installed python.
And if I try to install pygtk locally using the command
./configure --prefix=/home/shrihari/local/lib/pygtk2.24/
It gives the following error
checking for GLIB - version >= 2.8.0... yes (version 2.28.6)
checking for PYGOBJECT... yes
checking for gio-types.defs... no
checking for ATK... yes
checking for PANGO... yes
checking for codegen... configure: error: unable to find PyGObject codegen
My default python version is python2.4. If I try to import pygtk in python2.4 it works fine but i need pygtk in python2.7.
So how can I achieve this?
If there is any good documentation available for installing python, pygtk, pygobject locally in user space please share.
Thanks in advance
In general, to be able to link a build to something already installed, you need to have set up the LD_LIBRARY_PATH and (for Python modules) PYTHONPATH to the directories where you have installed that "something". So in this example, if you install Python 2.7 with prefix /home/shrinari/local/python27, you need afterwards set the system variables like this (for bash):
export LD_LIBRARY_PATH=/home/shrinari/local/python27/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/home/shrinari/local/python27/lib/python2.7/site-packages:$PYTHONPATH
export PKG_CONFIG_PATH=/home/shrinari/local/python27/lib/pkgconfig:$PKG_CONFIG_PATH
And after that you can try to compile something dependent on your new Python installation.
But, according to the configuration error provided, I don't think this helps in your situation. It seems that you have something missing from PyGObject, maybe just header files, maybe some module (I don't know PyGObject specifics). Anyway, why the configure script can not find something is usually better visible from config.log file which can be found in the build directory after running the configure script.
This error is because of compatibility between pygobject and gobject-retrospection. To avoid this use Pygobject build earlier than 2.90.1 if your GTK is old. I Used following on CentOS 5.5 to make it work -
pygobject-2.28.6
When building pygobject disable introspection with --disable-introspection
gobject-retrospection 1.32.1
I am running a MacBook Pro with 8gb of memory and a 2.5GHz processor. I run OS X Mavericks, but this problem has happened on other operating systems as well. when I try to open the editor, or even open a python file, this happens:
This has been a problem since I got into python. I have tried as many versions as I can, and the same screen pops up. Please help
I recently also upgraded a friends iMac to OS X 10.9 Mavericks and her Python to 2.7.6. If you mount the python-2.7.6-macosx10.6.dmg disk image there's a text file named ReadMe.txt. If you ahem, actually read it, right near the beginning it says:
**** IMPORTANT ****
Update your version of Tcl/Tk to use IDLE or other Tk applications
To use IDLE or other programs that use the Tkinter graphical user
interface toolkit, you may need to install a newer third-party version
of the Tcl/Tk frameworks. Visit
http://www.python.org/download/mac/tcltk/ for current information
about supported and recommended versions of Tcl/Tk for this version of
Python and of Mac OS X.
Here's what http://www.python.org/download/mac/tcltk currently looks like (my highlighting):
To summarize: You need to download and install ActiveTcl 8.5.15.1 (which is mislabeled ActiveTcl 8.5.15.0) from ActiveState's webpage. After doing that you should be able to run IDLE:
I haven't actually tried to do it yet, but from what I read it sounds like the same process applies to Python 3.3.3 and its IDLE app.
I was having the exact same problem.
I was finally able to install Python (and IDLE) via MacPorts by also installing a package called "pyXX-tkinter" -- where XX is the version, e.g. py34-tkinter for Python 3.4.
I just fixed a bug in a two year old python program and now I'm having big trouble getting it to compile again. I simply cannot get Python, Cairo, wx and distutils to work together.
On OSX I managed to get Python 2.7 to import Cairo and WX but py2app does not work. The error is something about unknown architecture.
On Windows 7 I have not been able to successfully import cairo. I installed py2cairo and put the libcairo-2.dll in Windows/System32 but still get an import error. I even copied msvcr90.dll to System32 but still no luck.
Does anyone have a combination of Python, wx, Py2cairo, Cairo and distutils that just works? I need Python 2.6 or 2.7 32 bit on OSX and Windows.
I got it to work on OSX by installing an older version of XCode form the SnowLeopard DVD.
You also have to be very careful with paths to data files because py2app puts everything into a zip file.
py2exe was worse because it did not copy dynamically loaded modules and one dependency from pytz into the repo and needed some ugly hacks in setup.py.
I ended up using cairo-1.10.2, libpng-1.2.49 and pixman-0.20.2