I'm trying to use AWS CLI S3 within the Terminal (Mac OS X v10.6.8) and after configuring all of the proper credentials when I run basic commands (e.g., aws s3 ls) it does not output anything.
When I do a slightly more complicated command (e.g., aws s3 mb s3://newbucketname) it outputs: __init__() keywords must be strings.
Based on some research I suspected the cause is that Python 2.6.1 is installed by default, so I downloaded v3.3.2, installed it, and used the 'Update Shell Profile.command' feature to set the correct PATH variable.
Now with the new version of Python installed and configured I still get the same results. The Terminal still appears to be using the old version of Python, despite the $PATH variable pointing to the new version (v3.3.2).
Any help would be greatly appreciated. I'm guessing that it has to do with the Terminal not using the new version of Python and thus the AWS CLI functionality doesn't work, but there may be a different cause that I'm not aware of.
Thank you!
If you installed aws with the easy_install that came with Python 2.6, it will be hardcoded to use Python 2.6—its first line will be something like this:
#!/usr/bin/python2.6
This shebang line means that the script will run with /usr/bin/python2.6. Installing Python 3.3 won't change what's at /usr/bin/python2.6. It has nothing to do with what's on the PATH, or what the first thing called python is on the PATH. The PATH only comes into play if a script uses /usr/bin/env on the shebang line. And /usr/bin/env python2.6 would of course still find Python 2.6. In fact, even /usr/bin/env python would still find Python 2.6, because 3.3 doesn't have anything named python, just python3.
Meanwhile, even if you managed to hack it up to run with Python 3.3 instead (e.g., by changing that first line to /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 or /usr/bin/env python3), that would just make it break completely. The aws script requires the aws package to be installed into your site-packages. You've installed them into your 2.6 site-packages, but not your 3.3 site-packages. (On top of that, many packages install different code for Python 2.x vs. 3.x, so the 2.6 script might not work with the 3.3 package even if it were there.)
Anyway, the right way to fix this is to uninstall aws from Python 2.6, and re-install it for Python 3.3.
If you'd used pip as recommended, this would be trivial:
pip-2.6 uninstall awscli
pip-3.3 install awscli
Unfortunately, because you used easy_install instead, you have to uninstall it manually.
And really, you don't need to uninstall the packages, just the scripts that ended up in /usr/local/bin or somewhere else on your PATH. I suspect rm /usr/local/bin/aws* will take care of that, but be careful—make sure there's nothing else installed there that starts with aws but isn't part of the package.
Meanwhile, for the future, install pip and use that. For Apple's Python 2.6, use sudo easy_install pip to install it. For Python 3.3, follow the instructions at the pip site.
Related
I would like to install pip for the default installation of Python on Mac OS.
Please don't recommend brew, I already have it and installed Python 3 with it, but it seems that Automator only knows how to use the default version of Python located in /usr/bin/python That's the reason behind my specific request
I did my homework first, or tried to, before asking the question, but what I found confusing is that the recommended method seems to be using get-pip.py, but the pip documentation says
Warning Be cautious if you are using a Python install that is managed
by your operating system or another package manager. get-pip.py does
not coordinate with those tools, and may leave your system in an
inconsistent state.
This threw me off, as I don't want to risk breaking the default Python on Mac OS, as I understood that might mess my system.
I also didn't want to use the deprecated easy_install.
And I couldn't find an answer to my question, as usually the answers just recommend installing a different version of Python with brew.
Please don't recommend brew, I already have it and installed Python 3 with it, but it seems that Automator only knows how to use the default version of Python located in /usr/bin/python That's the reason behind my specific request
Can you possibly use "Run Shell Script" in Automator and specify the python version you want to use. See Specify which version of Python runs in Automator? and https://apple.stackexchange.com/questions/233890/calling-python-3-script-from-applescript
Problem
Seems like Automator isn’t loading /usr/local/Cellar/bin into your PATH. You can echo $PATH in Automator to confirm this.
Solution
Reinstall using brew and ensure that you run brew link python.
You can export PATH=... before running your script or move /usr/bin/python to /usr/bin/pythonx.x where x is the default version installed, then symlink /usr/bin/python to your brew installed python in /usr/local/bin/.
I have to use an API which uses Python 2.6 and am having a very difficult time getting it installed on my mac. I have downloaded it but figuring out what I am supposed to write in my bash_profile is exceedingly difficult. For all versions of Python that I have used so far I write
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export Path
in my bash profile. But I can't do that for python 2.6 because it does not have a bin folder. Does anyone know what I'm suppoed to write on my bash profile in order to get Python to use version 2.6?
I'm aware that one solution is pyenv but I tried that a long time ago and there were too many modules that I could not install with it so I don't like that program.
I'm also hoping brew will work but according to this page
https://formulae.brew.sh/formula/
python 2.6 is no longer available for brew install. And when I run brew install python#2.6 no formulae are found.
My current strategy is to try macports so we'll see how that goes.
Using Ubuntu 16.04.
I was doing development in Python2.7, although recently moved to Python3.5, both of which come by default. The problem is, I find all the python libraries have to be reinstalled or downloaded for the next Python3. Also, the behaviour of Python seems weird because to execute the same script in python3, I have to enter in terminal
python3 script.py
which is different from other applications where I do not have to give the version number. Anyway, the questions I am trying to find answers are
To what extent are the libraries, packages (such as pip etc.) shared between 2.7 and 3.5? Or do I need double installations (and double the space) for everything now? A bit space limited in my old laptop.
Most of the installation instructions and commands I find online do not specify whether they are for 2 or 3. Given that I have two versions, how do I control/make sure they go to 3.5?
Is it advisable and possible to completely remove everything related to 2.7? Can I keep working with 3.5?
The first thing you need to know is that all official libraries and python tools for python3 got the "3" character to separate them from the previous versions. So, you need to use pip3, and not pip, python3, not python, and the packages are called python-pygame, not python-pygame.
So, to answer to you in order:
Yes, the you have to double the space needed if you decide to use both python2 and python3
Usually, if in the tool name there is 3, it is for python3, and if not it's for python2
Python2 and python3 are completly indipendent (different path, indipendent versions, etc.) so having python 2.7 installed doesn't affect python3 BUT since python 3 is the next version of python 2, it makes it obsolete (in my opinion) so if you don't have enough space for both, keeping python2 is absolutely not needed nor useful
If you want to control your python execution then you have various method or techniques:
For downloading packages according to version
You can use pip{version-name} to download the libraries. Like if you want to download library of python 2.7 then write
pip2.7 install package-name
for python 3.5 then use
pip3.5 install package-name
For execution of program:
If you want to execute the program accoridng to you choice of version then just use
python{version-name} script.py
eg:
python2 script.py
python3 script.py
or you just write down the path of your python version on the top of script. Please refer this for more details:
Why do people write #!/usr/bin/env python on the first line of a Python script?
As you can see by reading my other thread today here, I'm having some troubles upgrading Python.
At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an application that requires 2.5 which has resulted in me installing that and getting into a whole load of mess. My original assumption was that I could direct Django to a different Python version, however as S.Lott informed me, I had it backwards... you attach Django to Python, not the other way round. Which means I currently have: Python 2.4 with Django and Python 2.5.
I've tried a few things so far to no avail. The first idea being an easy_install which would put Django onto the Python 2.5 (So I'd have 2 versions of python with seperate Djangos). Therefore I went into 2.5's directory and did that, which then allowed me to find out that it had just reinstalls it on 2.4, not 2.5. Therefore first question is How do I direct easy_install to Python 2.5, not 2.4?
Is there no way to just hit 'upgrade' and for a full update to occur? I know this may be asking for much, however it just seems like so much hassle and I'm surprised I can't find anyone else complaining. Any help would be greatly appreciated.
I don't know anything about CentOS, but if you have multiple Python version installed and you wan't to install packages using easy_install, you just need to call it with the corresponding Python interpreter. This should install the packing into the site-package directory of Python 2.5:
# /path/to/python-2.5 easy_install Django
assuming your python2.5 interpreter lives in /usr/bin/python2.5, you can install setuptools for python2.5 as such:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo /usr/bin/python2.5 ez_setup.py
Among other things, this installs an "easy_install-2.5" script in your $PATH (check the output of the above command).
Now you have two easy_install scripts: one for python 2.4 ("easy_install") and one for python 2.5 ("easy_install-2.5").
To install Django for your python2.5, use
sudo easy_install-2.5 django
That's it!
easy_install is a shell script the first line of which tells it where python is installed (I am on OSX so can't say exactly what your directories will be )
So you could copy easy_install and change the first line to point to 2.5. (or do as Heas suggests)
Althernatively when you installed python 2.5 there might be a file easy_install-2.5 with the correct python (again these were installed for me under OSX so might be a special version)
You don't need to 'install' Django at all, it just needs to live on the Pythonpath somewhere. Assuming it's currently in the Python2.4 site-packages directory, you can just move it to the 2.5 one:
sudo mv /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django
or whatever the correct path is for CentOS.
However, as I noted on your other question, this won't necessarily help - S.Lott was unfortunately misleading in his answer. To serve Django via modpython or modwsgi with a new Python version, you'll need to recompile those extensions or download packages versions precompiled with Python 2.5.
I'd like to how to upgrade the default python installation(2.5.2) supplied with ubuntu 8.04 to python 2.6rc2. I'd like to make 2.6 the default python version on the system and migrate all the other useful installed python libraries installed on 2.5.2 to python 2.6rc2. Please let me know how I can achieve this.
Thanks
Dirk
With the warning that I think it's a tremendously bad idea to replace the default Python with an unreleased beta version:
First, install 2.6rc2. You can download the source from the Python website. Standard ./configure && make && sudo make install installation style.
Next, remove the /usr/bin/python symlink. Do not remove /usr/bin/python2.5. Add a symlink to 2.6 with ln -s /usr/local/bin/python2.6 /usr/bin/python.
Once again, I think this is a terrible idea. There is almost certainly a better way to do whatever you're trying to accomplish.
Migrating installed libraries is a much longer process. Look in the /usr/lib/python2.5/site-packages/ and /usr/local/lib/python2.5/site-packages/ directories. Any libraries installed to them will need to be re-installed with 2.6. Since you're not using a packaged Python version, you cannot use Ubuntu's packages -- you'll have to manually upgrade all the libraries yourself. Most of them can probably be installed with sudo easy_install <name>, but some like PyGTK+ are not so easy. You'll have to follow custom installation procedures for each such library.
I have the same issue, and apparently pre-built binaries can be found here:
# Python 2.6
deb http://ppa.launchpad.net/doko/ubuntu intrepid main
deb-src http://ppa.launchpad.net/doko/ubuntu intrepid main
Is there any need to?
Ubuntu in general doesn't package RC releases. 2.6 will not be available in Ubuntu until Jaunty Jackalope.
However,, if you insist that you need to install it, then, you'll have to do so without a package manager.
Download the package, and unzip it to a directory
run the following commands (waiting for each to finish as you do so)
./configure
make
sudo make install
There, you have it installed.
It's better to wait for it to be packaged first, espescially as Python is used in a lot of ubuntu internals, so may break your system horribly
It would not be wise to change the default version of Python, i.e. what you get when you type "python" into a shell. However, you can have multiple versions of python installed. The trick is to make sure that the program named "python" on the path is the system supplied version. If you want to run your install of Python 2.6 you'd then type python2.6 into a shell to start it.
Download the package and unzip it, then run:
./configure
make
sudo make install
ls -l /usr/local/bin
You should see a python and a python2.6 file, both created on the day you ran make install; delete the python file. Then when python is launched the standard system Python version from /usr/bin will be run, and when python2.6 is run you get your shiny new python 2.6rc2. Python displays the version when it starts an interactive interpreter.