I'm new to programming and to be more specific, Python. I was going through the installation process from Robert Sedgewick's Introduction to Programming in Python website until right before the section "Downloading and Installing the Booksite Library". My problem occurred with:
In the Terminal window issue the command idleX.Y (for example, idle2.7). If an IDLE window appears, then you have installed IDLE properly. Close the IDLE window.
As I was installing Python 2.7, I attempted to use the command idle2.7, but I received the following response. As far as I can tell, I followed all of the directions provided by Mr. Sedgewick's website and I have already verified that Python was being installed as version 2.7.10. After looking for answers online, I found a similar one here on Stack Overflow. Unfortunately, the potential solutions listed for that question didn't help resolve my issue. At this point, I should mention that I am trying this on a MacBook Pro (2015 model) running the latest version of OS X (El Capitan).
Thanks for your help!
For 2.7, the following, where 'python' is 'whatever string needed to start 2.7' (perhaps 'python', perhaps 'python2'), should work on any OS:
python -m idlelib.idle
For 3.x, .idle can be omitted. In *nix (but not on Windows), python should probably be replaced by python3. The usability of shortcut scripts such as 'idle2.7' depends on the script being both present and on the executable path. That, in turn, depends on the specific installers. In the last year, Python core developers have veered away from the use of a multiplicity of short-cut scripts, which are not dependable, toward python -m module, which is dependable as long as one can start a particular version of Python. On Windows and, I believe on Mac, after using the PSF installers, python can be replaced by py -x or py -x.y if one has multiple python installations.
Related
Good day everyone, I just bought a system with window 8. I downloaded Python 3.10 and after installing it,to my surprise, the Idle does not open when I click, although the command prompt is working. I've tried all possible best to resolve this, all to no avail. How can I overcome this?
With the given details, I can't say something that will work 100% but there are people who were dealing with similar issues:
I had this issue too, I realized that I had installed the 32bit version on a machine running 64bit. So I uninstalled and installed the 64bit and it's fine now.
or
Can you launch Python from a command line and then launch IDLE from there?
cd c:\python33
python
After python starts, enter the following:
import idlelib.idle
I suggest you either try these methods or just straight up reinstall Python to your computer. But be sure to download the right one for your hardware.
Source:https://bugs.python.org/issue16365
Another place which you can visit as well:Python IDLE shell not opening
Again, you need to provide more detail.
I'd like to reset the python terminal command path to the pre-installed version 2.7 on OS X 10.11.3. I never had any path issues on my previous machine, whether it was installing packages to certain versions or avoiding breakages etc. The additions I made to my new machine shouldn't have altered how the python command is set (according to docs and the book I'm using). I don't consider myself a Terminal power-user. I appreciate any help. Details of those additions and what research I have already done follow:
Python 2.6 and 2.7 were pre-installed and the python command launched version 2.7 before I made any changes.
I installed Python 3.5.1 from python.org using python-3.5.1-macosx10.6.pkg, and at that stage python launched ver. 2.7 and python3 launched ver. 3.5.1. This is in-keeping with my previous machine and the book I'm using now: "Python 3 will be installed as /usr/local/bin/python3, leaving any existing Python 2 on your computer unchanged." (Introducing Python by Lubanovic)
I installed Anaconda 3 from continuum.io using the Python 3.5 graphical installer Anaconda3-2.5.0-MacOSX-x86_64.pkg, and following the walkthrough in Introducing Python: "Anaconda installs everything in its own directory (anaconda under your home directory). This means that it won't interfere with any versions of Python that might already be on your computer." The Read Me supports this: "The 'Install for me only' option will install anaconda to the default location, ~/anaconda."
While I am very familiar with certain packages within Anaconda, I have never used Anaconda before. Likewise I didn't think a second install of Python 3.5.1 in a unique directory would mask or conflict either of the other versions.
However, I suspect that this is where I went wrong. The Anaconda Read Me also states: "By default, this installer modifies your bash profile to put Anaconda in your PATH. To disable this, choose "Customize" at the "Installation Type" phase, and disable the "Modify PATH" option. If you do not do this, you will need to add ~/anaconda/bin to your PATH manually to run the commands, or run all anaconda commands explicitly from that path." Please bear in mind, this consideration is not found in the install walkthrough in Introducing Python. I didn't address this one way or the other, so the default was carried out by the installer.
At this stage, both python and python3 launch Python 3.5.1 from Anaconda 2.5.0; only python2.7 launches Python 2.7.
Perhaps there is some way to test how much trouble this might cause.
I haven't explicitly altered or created any aliases, any paths, or any other environment variables. Ned Deily provided thorough-going info in several QnAs. In QnA How to set default Python version in terminal on OS X 10.6.8? he specifies: "The python.org installers for Python 3.x on OS X do not select the shell script modification option by default. You can enable it at installation or you can later run the Update Shell Profile.command file in the corresponding Python x.x folder in the Applications folder. Or you can just manually edit the right profile." I haven't run Update Shell Profile.command of course. Moreover, this info is concurrent with the outcome from my initial 3.5.1 install, but seems contrary to the bash mod info provided in the Anaconda Read Me. But again, I don't know enough about the inner-workings to execute the correct prognosis.
I am to blame for not reconciling the Read Me with the walkthrough prior to the install. I have already researched uninstalling Anaconda, which looks like it creates breakages and hassles. Most of the related QnAs here are concerned with setting or changing the pre-installed system-friendly version to Python 3. After reading through a half-dozen of these QnAs I would be comfortable with performing that change, but I want to do the opposite. It's also possible that I should run tests or check the results of certain terminal commands prior to changing anything. I don't want to attempt anything (the inverse of instructions in a QnA, for example) without expert advice. For an expert I'm sure it's a minor point; thanks for your patience.
Using info provided by waitingkuo in QnA How to set default Python version in terminal on OS X 10.6.8? I have included the current state of my ~/.bash_profile:
# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
# added by Anaconda3 2.5.0 installer
export PATH="/Users/shawnchristopherburke/anaconda/bin:$PATH"
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/.bash_profile" 8L, 267C
In QnA how to change default python version? Adam Vandenberg said that altering which version python launches might not break things in OS X: "Any system software would be using the full path to the system provided Python." That makes me feel better, but I would like to put things back the way they were to ensure compatibility, especially with pre-existing pathnames. Why would Anaconda not default to exercising caution the way python.org installs of Python 3 do? Anxiety is a factor; it is a new machine.
I understand even though I've written at length here, likely there are key details missing. Please let me know if there's any other info I can provide. I'm accustomed to using multiple versions of Python at will, with as few low-level adjustments as possible (first time I've ever looked at .bash_profile for example). So thanks in advance for the education to overcome this hang-up.
How do I install GVIM for Windows with Python3 support? I have installed VIM 7.4 which says in it's version file (run :version command) "+python3/dyn" and "-DDYNAMIC_PYTHON3_DLL=\"python32.dll\". So it looks like it's ready to support Python 3. When I run
:echo has("python3")
it returns zero. And if I test with
:py3 print("hello")
it says it cannot load python32.dll.
Here is an approach that I used to get VIM 7.x to work with Python 3.x.
Install a VIM of your preference. Suggestion: get the latest version from VIM.org, though this site seems to have only 32-bit versions. If you want 64-bit (my preference) get a pre-built at https://bintray.com/veegee/generic/vim_x64 or choose your own pre-built elsewhere, or build your own.
Type the command :py3 print("hello")
It probably will not find the python dll, in which case it gives an error message like cannot load pythonXX.dll where XX is a two-digit number. In my case, VIM was looking for python35.dll, which comes from Python 3.5.1 (and probably any Python 3.5.x). The number will vary depending on the version of VIM you use.
Go find a matching Python distribution. Matching means that both VIM and Python must be either 32-bit or 64-bit, and the DLL that VIM wants (in step 3) is present. So for example, it appears that Python 3.5.x provides python35.dll. Install it.
I don't recall having to do anything special to get VIM to find the python DLL, other than ensuring that the directory it is in should be in the path, and I think it already was. If not, add the directory with the DLL to your path.
Retry step 2. It should work now.
If in the future you upgrade VIM or Python, you may need to upgrade the other one at the same time, to ensure that the test in step 2 still works.
The problem that makes this question so hard is that specific solutions very quickly become obsolete. The day the solution is posted the version of vim or python is updated or links change. The steps provided by #mark-colon are fantastic but oriented for vim-7.
Generic instructions:
vim and python need to be in sync on many different levels:
Both need to be 32bit or 64bit
Vim needs to find a specific python dll version. It depends on who compiled your version of gvim. For example, gvim-8.1.x may use python3.6 or python3.7 and the exact version is required! Sometimes you can use: gvim --version to see what specific dll is being searched by vim at launch, otherwise you need to find out from where you downloaded gvim. This is the version of python that you must search the internet and install on your system. (Alternatively, if the version of python is more important to you than the version of vim, you can try to find a version of vim that was compiled for python but this will be harder to find.)
Make sure the directory that holds the python dll needs to be on the %PATH% environment variable. (Note: some just copying the python dll to the $VIM folder to get things working only works in the short term. You don't have all the necessary python libraries that are often assumed to be available.)
Finally, verify with ex command :python2 print("hello") or :python3 print("hello") depending on what version of python you wanted.
Specific links (if you must):
Note: these will all soon be out of date, but the following are some links to various compiled versions of gvim and python that could work together:
For gvim-8.1.x & python-3.7.x or python-2.7.x as of 2018-08:
https://tuxproject.de/projects/vim/
http://winpython.github.io/ or https://www.python.org/downloads
For gvim-8.1.x & python-3.6.x or python-2.7.x as of 2018-08:
https://github.com/vim/vim-win32-installer/releases
https://www.python.org/downloads
For gvim-7.4.x & python-3.5.x or python-2.7.x as of 2018-08:
https://bintray.com/veegee/generic/vim_x64
https://www.python.org/downloads
Unfortunately this took me a day to figure out. Here's the simplest way to remedy this problem, if you are looking to have Python3 support with GVIM 7.3+ on Windows.
I am running 64-bit Windows 8, but, make sure you grab a 32-bit version of Python. You will most likely have a 32-bit version of GVIM by default, and those 2 need to match. Specifically, grab a 3.2.x version of Python3 because that's what VIM is looking for as far as a DLL is concerned (python32.dll). Don't bother with the latest version of Python 3, 3.4.0 at the time of writing; and if you do need that, then I'm not sure how to help.
Once you have Python 3.2.x installed, make sure you do this last tricky part:
The python32.dll is not placed in system32 folder, it is actually in the C:\Windows\SysWOW64 folder. You need to add "C:\Windows\SysWOW64" to your PATH environment variable.
Now re-try your python3 tests in GVIM and it should be successful.
I use Haroogan's compiled version, it's great and has a 64-bit version for windows.
EDIT:
veegee's version seems to be a good alternative. Thanks to Markus Meskanen in the comment.
I have tested that you should use the same architecture for both vim and python.
see https://vi.stackexchange.com/questions/11004/how-to-get-python-support
If you just need python feature in vim, download python36.dll and put in $VIM and verify by :echo has('python3')
I have a launchd entry that worked with OSX 10.6 but that fails with 10.7. It uses python, and it produces an error whilst trying to import serial. I don't quite understand this, because I've re-downloaded pyserial-2.5 and re-installed it with sudo. (In desperation, I re-installed it for each of the many flavours of python on my machine.) As a test, I can enter python and do import serial without difficulties. Maybe there is a system path that is set up well for an interactive user, that is not set up for launched??
Can anyone suggest how I might diagnose the problem?
The path you are appending:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
is the site-packages directory for a third-party, non-system Python, possibly installed using a python.org installer, and not that of the Apple-supplied system Python 2.7, which would be:
/Library/Python/2.7/site-packages
So most likely you are using the python.org Python to install pyserial but are launching the system Python under launchd. Check your shell PATH (echo $PATH), it probably has:
/Library/Frameworks/Python.framework/Versions/2.7/bin
in it. And try which python. If you want to use the python.org Python with your launchd plist, modify it to use an absolute path to the right Python, for instance:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
If you want to install pyserial with the system supplied Python, you can use an absolute path to it when doing the install:
/usr/bin/python2.7
Some experimentation with python -S showed me that the sys.path was not set up properly, so I solved the issue by
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')
import serial
which I know is awkward, since it is so specific, but I guess I'll have to live with that, unless or until I can find a way to tell python where to find things, as it is being invoked from launched.
PS to anyone coming here later: the switch to OSX 10.7 (Lion) changed loads of things. Perhaps I had some initialization file somewhere, that I forgot about. If I find that, I'll try it that way, and post a further comment here.
How do I get python to work with aptana studio?
I've downloaded a bunch of stuff, but none of them seem to give me a straight text editor where I can interpret code into an executable type thing. I know there's interactive mode in IDLE, but I want to actually use an editor. So I downloaded the pydev extensions for Aptana studio, but it wants me to configure a python interpreter (so I guess it actually doesn't have one). Where can I find a straight python interpreter that will work with this? or another IDE?
It's easier than you think. First, there's a version of python on your machine by default. It's kind of out of date, though.
MacPorts is a nice method to get lots of good stuff.
ActiveState has a Python Mac package downloadable for free.
Python.org will lead you to some other options as well.
To add the current Python version on Mac:
Add new interpreter via Aptana Studio 3/Preferences/PyDev/Interpreter-Python.
Give it name (check version using the Terminal and then python or /usr/bin/python.
Then add the path (2.7 in my case): /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
If you install your own (2.6 in my case) use the following path instead:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Don't forget to hit the "Apply" button...
Idle has a complete text editor -- open a "new window" and type away. Be sure to save it before you run it.
What didn't you like about the IDLE editor?
Also, look at Komodo Edit for Mac OS X. Very nice.
For windows, I'd recommend the aforementioned ActivePython. Mainly because it comes with Python win32, which you're going to end up installing anyway.
Secondly, if you're coming from the world of Java and C#, you might be expecting too much out of your IDE. I eventually found that more powerful IDEs just made things more difficult than they helped. So my advice is to try to go with something simple. In other words, go with something that will let you jump in and start coding rather than bugging you with a lot of features you probably won't need anyway. :-)
EDIT: One other thing, find and install pip. It makes installing python packages so much easier.
A lot of the sites in the Windows list mirror the Mac list.
Python.org has Win32 and Win64 installers.
ActiveState has a free Python Win32 package downloadable for free. There is no Win64 version (yet?).
PyWin32 is a Python package with extra modules for interfacing with Windows. This is not Python itself. These haven't been updated for Python 3.0, though. Despite the name, there is a Win64 version for Python 2.6 on this site.
On Mac OS X Leopard and Tiger, Python is already installed.
On Mac, I've tried a few editor. Textmate is my current choice. If you're looking for a free one, I really liked Xcode. But you'll have to run your script from the command line.
If you want a cross-platform environment, you could try Eclipse and the pydev extension. So you don't get lost between the two platform.
For Windows Operating system,
If you want to work with python using Aptana Studio. You have to do some simple basic settings with the interpreter.
For detailed step by step guide. You can follow this website link
http://www.infoknol.com/aptana-python-setup-guide/