I have been fighting with PyCharm on my OSX machine for a while, trying to understand why it can't find some things in mpl_toolkits. I have pretty well decided that the problem is that something went wrong with the matplotlib build in the default python interpreter that PyCharm uses. This is a Mac "framework" build located in /System/Library/Frameworks/Python.framework.
I have tried to solve this in two ways. First, I made sure that I had another working python interpreter -- able to deal with mpl_toolkits with no problem -- and then pointed PyCharm to it instead of to the default interpreter. When I do that, PyCharm can't even use matplotlib, let alone mpl_toolkits, because -- as it tells me -- I am not using a "framework build". Second, I tried to monkey with the default build and re-build matlotlib within it. Can't do it because the system won't let me touch it even if I am running under sudo.
So, I either need to
create my own "framework build" of python or
figure out how to get around the system prohibitions and re-install matplotlib in the existing "framework build".
I have looked around on the internet and can't find much on how to do 1. Can't find anything on how to do 2, and it seems kind of dangerous anyway.
Does anyone know how to do either of these?
Anyone have another approach that might work?
Related
Image link of directory structureNothing happens if I press Ctrl+Alt+B in my python project on IntelliJIdea and it feels as if this feature is not supported for Python in IntelliJ, from whatever I read, PyCharm has this feature, and considering both are from JetBrains, I fail to understand how that is not working.
Same for library method options, I've installed scikit-learn in my conda environment but when I press control+space after scikit-learn. I don't see any suggestions coming my way. I need solution to both these issues, if IntelliJ does support both these features for python or I've to go to pyCharm which is kind of a let down honestly.
I have been trying to graph with python for some time now. I want to use matplotlib, but have hit so many bumps in the road. Previously, numpy and matplotlib have been installed, but I am stuck with this error: ImportError: numpy.core.multiarray failed to import. I'm running Lion on Mac. I think I'm using Python 2.7. I have also tried full walkthroughs, such as this as well: http://penandpants.com/2012/02/24/install-python/. After several installation methods like pip and homebrew I am afraid that there's a lot of knotted things going on with python on my computer. And I really don't know how to untangle it.
I am reasonably knowledgeable with programming and algorithms, but I lack the know-how on how all the add-ons such as matplotlib that connect with python or how a text editor that can execute my code like Sublime Text 2 accesses them. So, as much as I would like to aid this asking-a-question process by letting you know what versions I am using, I don't really know how. Any guidance to how python connects to these things would be really appreciated :)
Ultimately, I wish to start from scratch with this whole mess, reinstalling python and then matplotlib from the ground up--but I'm not totally sure how. So, I guess my final question is how do I do that, or if that is just a wrong line of thinking how do I proceed if I want to graph some mathy things with python?
Sorry for the long winded question, I'll appreciate any help even a nudge in the right direction in learning how my computer organizes python on my computer!
Thanks!
I've had similar problems and the best solution I found was to use MacPorts for managing python and my installed modules. The things that I particularly like about using MacPorts for this are:
You can easily install multiple python versions (with modules separately installed for each installation)
You can select which python installation is the default (whether it is one installed by MacPorts or your OS X python installation).
Many MacPorts packages have optional variants so you can easily customize how they are installed (e.g., should numpy use the ATLAS library from MacPorts or from OS X) .
If you screw up your installation, you can easily wipe MacPorts from your system without worrying about breaking anything (almost everything installed by MacPorts is put under /opt).
As the title states i need to watch a directory for changes(mainly for file additions) using python
I stumble upon a few solutions here but none of them work properly
1.One solution was using "fcntl", I tried it on my system but it failed with an error "no attribute F_SETSIG".Googling it resulted in nothing useful
2.Python module Watchdog fails to install as i don't have xcode, which i don't want to download(too big to download and lots of unnecessary things for such small work)
The accepted solution was windows specific and none of others work on osx without big packages
So in the end I don't want any solutions involving XCODE, PyQT, polling, busy loop(i.e. checking DIR every few seconds)
Applescripts support this by default, so I think python should too without any big modules/packages
I am using OS X 10.7.2 and python 2.7.3 by the way
Thanks in advance
The API you want to be using is the FSEvents API. Python doesn't ship with bindings to that API, so you'll need to either make your own bindings or use a library such as MacFSEvents or python-watchdog. However you really should just install Xcode -- these libraries require compiling the C bindings, and Xcode is the easiest way to get a C compiler.
If you really want to avoid Xcode, you could roll your own bindings using the ctypes module, but that's going to be a big pain in the neck.
Applescripts support this by default, so I think python should too without any big modules/packages
Tough luck. The various 3rd-party libraries which are available are not that big, they just need a C compiler to work.
I use watchdog right now on osx. It works great. Install xcode. Or just the command line tools for the compilers.
You can install the gcc compiler without xcode: https://github.com/kennethreitz/osx-gcc-installer
If you really want an applescript approach you can use the python bindings appscript: http://appscript.sourceforge.net/py-appscript/index.html
I use those too and they work great.
So in the end I don't want any solutions involving XCODE, PyQT, polling,
busy loop(i.e. checking DIR every few seconds)
Basically you are saying you dont want anything at all. Any solution is going to use a form of polling. Whether its system triggered or app busy loop. You just need to take a second to install the compilers to use the solution of your choice.
After using C# for long time I finally decided to switch to Python.
The question I am facing for the moment has to do about auto-complete.
I guess I am spoiled by C# and especially from resharper and I was expecting something similar to exist for Python.
My editor of choice is emacs and after doing some research I found autocomplete.pl, yasnippet and rope although it is not clear to me if and how they can be installed in a cygwin based system which is what I use since all the related documentation appears to be linux specific...
The version of emacs I currently use is 23.2.1 which bundles the python mode that although useful is far behind from whatever research has to offer.
My question to python users has to do about how common is autocomplete vs manual typing (using M-/ where possible) ?
I am thinking about just memorizing python build-in functions like len, append, extend etc. and revert close to a pre-autocomplete editing mode. How different such an approach is from what other pythonistas are doing?
I found this post
My Emacs Python environment
to be the most useful and comprehensive list of instructions and references on how to setup a decent Python development environment in Emacs regardless of OS platform. It is still a bit of work to setup but at least it covers the popular packages and components generally recommended for Python in Emacs that provide auto-completion functionality.
I loosely used this post as a guide to do the setup on my Windows machine with Emacs 23.2.1 and Python 2.6.5. Although, I also have Cygwin installed in some cases instead of running the *nix shell commands mentioned in the post, I just download the packages via a web browser, unzip them with 7zip, and copy them to my Emacs' plugin directory.
Also, to install Pymacs, Rope, and Ropemacs, I used Python's EasyInstall package manager. To use it, I downloaded and installed the setuptools package using the Windows install version. Once installed, at the command line, cd to their respective download locations and run the command
easy_install .
instead of the shell commands shown in the post.
Generally, I saved any *.el files in my ~\.emacs.d\plugins (e.g. in %USERPROFILE%\Application Data\.emacs.d\) and then updated my .emacs file to reference them as documented in the post.
Despite all this, on occasion, I've used DreamPie since it does have overall better auto-completion out of the box than my Emacs setup.
I'm spoiled by Intellisense too. The PyDev extensions for Eclipse offer a pretty good auto-complete substitute.
I find that PyDev + Eclipse can meet most of my needs. There is also PyCharm from the Intellij team. PyCharm has the added advantage of smooth integration with git.
I've been using PyScripter, an IDE for Windows, for a while now, and have found it very good. It has autocompletion among many other features. It's written in Delphi -- not that there's anything wrong with that -- it just bothers me a bit, though...
Take a look at Spyderlib, support most of the features including code completion
IMO, by far the easiest way to take advantage of the python tools available for emacs is to take advantage of the defaults that are all set up at:
https://github.com/gabrielelanaro/emacs-for-python
I actually took the time to get pymacs and ropemacs and python-mode all working independently before finding that little gem, and now I rely on it entirely for all my python based customizations. If you are new, I would definitely start there.
I bought a low-end MacBook about a month ago and am finally getting around to configuring it for Python. I've done most of my Python work in Windows up until now, and am finding the choices for OS X a little daunting. It looks like there are at least five options to use for Python development:
"Stock" Apple Python
MacPython
Fink
MacPorts
roll-your-own-from-source
I'm still primarily developing for 2.5, so the stock Python is fine from a functionality standpoint. What I want to know is: why should I choose one over the other?
Update:
To clarify, I am looking for a discussion of the various options, not links to the documentation. I've marked this as a Community Wiki question, as I don't feel there is a "correct" answer. Thanks to everyone who has already commented for their insight.
One advantage I see in using the "stock" Python that's included with Mac OS X is that it makes deployment to other Macs a piece of cake. I don't know what your deployment scenario is, but for me this is important. My code has to run on any number of Macs at work, and I try to minimize the amount of work it takes to run my code on all of those systems.
I would highly recommend using MacPorts with Porticus for managing your Python installation. It takes a while to build everything, but the advantage is that whatever you build yourself will be built against the same libraries, so you won't have to futz around with statically linked shared objects, etc. if you want your Python stuff to work with Apache, PostgreSQL, etc.
If you choose to go this way, remember to install the python_select port and use it to make your system use the Python installed from MacPorts.
As an added bonus, MacPorts has packages for most main-stream Python eggs, so if you should be able to have MacPorts keep you up-to-date with the latest versions of all that stuff :)
Here's some helpful info to get you started. http://www.python.org/download/mac/
Depends what you are using python for. If you are using MacOS funitionality and things like PyObjC you are probably best of with MacPython or the python provided by Apple.
I use Python on my Mac mostly for development of server side applications which later will run on FreeBSD & Linux boxes. For that I have used fink python for a few years and ever since MacPorts python. With mac ports it is simple to add required c modules (like database driver etc). It's also easy to keep two python Versions (2.5 & 2.6 in my case) around.
I used "compile your own" python to test pre-3.0 python but generally I find managing dependencies to c modules painfull if done by hand.
Thanks to easy_install installing pure python modules is fast and easy for all the options mentioned above.
I was never very much an IDE person. For development I use command line subversion installed by MacPorts, Textmate and occasionaly Expandrive do directly access files on servers. I personally are very dependent on Bicyclerepairman for Textmade to handle my refactoring needs.
Others seem to be very happy with Eclipse & Pydev.
How about EPD from Enthought? Yes, it's large but it is a framework build and includes things like wxPython, vtk, numpy, scipy, and ipython built-in.
I recommend using Python Virtual environments, especially if you use a Timecapsule because Timecapsule will back everything up, except modules you added to Python!
Based on the number of bugs and omissions people have been encountering in Leopard python (just here on SO!), I couldn't recommend that version. e.g., see:
Why do I get wrong results for hmac in Python but not Perl?
Problems on select module on Python 2.5
I would choose MacPorts.
It does not eliminate your existing python supplied by Apple since it installs by default in /opt/local/bin (plays nice with it) and plus it is easy to download and install additional python modules (even binary modules that you need to compile!). I use Porticus GUI to maintain my MacPorts installed list of packages, including python.
In my windows environment I use Eclipse and PyDev, which works quite well together, even if it's a bit sparse. Apparently the exact same environment is available for the Mac as well, so I suggest downloading Eclipse and using the internal update software function to update PyDev with the URL http://pydev.sourceforge.net/updates/. To look further into PyDev, look here.
Apple's supplied python is quite old – my tiger install has 2.3.5. This may not be a problem for you, but you would be missing out on a lot. Also, there is a risk that Apple will update it. I'm not sure if moving from 2.3.5 to (say) 2.4 would cause code to break, but I guess it's possible. This happened to perl people recently: http://developers.slashdot.org/article.pl?sid=09/02/18/1435227
Macpython is a framework build (as is Apple's, I believe). To be honest, I'm not sure exactly what that means, but it's a prerequisite for some modules, in particular wxPython. If you get python from macports or fink, you will not be able to run wxPython (unless you run it through X11).
And guess what was forgotten by every answer here ... ActivePython.
No compilation required, even for third-party modules such as numpy, lxml, pyqt and thousands of others.
I recommend python (any python?) plus the ipython shell. My most recent experience with MacPython was MacPython 2.5, and I found IDLE frustrating to use as an editor. It's not very featureful, and its' very slow to scroll large quantities of output.