Python 3to2 Tool - Requires At Least - python

So, I'm using 3to2 to port my Python 3.3 code back to version 2.x. I, believe, I correctly installed 3to2 by downloading the .tar.gz, cd to the file and running python3.3 setup.py build and then python3.3 setup.py install, so I don't think that is what is causing the issue.
The issue: the issue is that after I cd to the correct file, with the code I wish to use 3to2 on, I run 3to2 filename.py, which then returns the following:
Checking Python version info...
ERROR: 3to2 requires at least Python 2.7 in the 2.x branch.
Now, I have Python 3.3 installed, which I did myself and Python 2.7, which came pre-installed on my [Mac - OSX Lion 10.7.3] computer. Any ideas why this may be? Thanks!

Even though this question is pretty old, I figured I can still help if anyone else has this same issue.
If you've installed 3to2 already, uninstall it. I used pip, so if you did too, run a pip uninstall 3to2.
If you're on OSX, do a quick python --version and make sure that your current version is 2.7.*.
To get a working version of 3to2 run 'sudo python -m pip install 3to2'.
Now, when you run 3to2, it will be referencing the correct python version.

I feel your pain I spent the last hour troubleshooting this issue on my mac, below is what I did...
Open terminal, type :
brew install python
note : brew might mention that python is already installed, or that it's installed but unlinked... either way. Then type :
brew link --overwrite python
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
If this doesn't work try typing brew doctor, I would have never been able to fix my problem without it's feedback..
This fixed my problem, but there might another way...

Related

No module named pip on macOS Big Sur

I'm running macOS 11.2.2 Big Sur and I'm trying to get pip to work with the latest Python 3.9.4. This turned out to be ridiculously difficult even though I've read a number of articles on the subject. Possibly, it is the debris I accumulated in the system over the years which is causing me trouble. I need advice as to how to get things right again.
Checklist:
/usr/local/opt/python/bin/python3 --version is Python 3.9.4 installed from brew in the most usual way; it's a symlink to ../Frameworks/Python.framework/Versions/3.9/bin/python3, which is in Cellar.
Both python and python3 commands are aliased to /usr/local/opt/python/bin/python3, they give the correct version.
I used both get-pip.py and ensurepip, and both of them say everything is fine: "Successfully installed pip-21.1.1 setuptools-56.0.0"
The only thing in env that has anything to do with Python is this part of PATH: /usr/local/opt/python#3.9/Frameworks/Python.framework/Versions/3.9/bin. The lack of this one is reported as warning when you install pip.
Still, I get this:
python -m pip --version
/usr/local/opt/python#3.9/bin/python3.9: No module named pip
What am I missing? 🤯
I also found this article that instructs to use pyenv, but running it on the latest macOS is yet another problem: pyenv install 3.9.4 doesn't build for some reason.
Using pointers from #gold_cy in the comments I was able to resolve the problem by running get-pip.py with an additional parameter: --prefix=/usr/local/.
While the official pip installation guide does mention that there may be problems on the systems like macOS that manage their own Python install, it doesn't say directly what you can do about it. Which is a shame, because the phrasing in PyPA » Python Packaging User Guide » Tutorials » Installing Packages is exactly the same, only the last phrase is missing from pip's page:
Warning Be cautious if you’re using a Python install that’s 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. You can
use python get-pip.py --prefix=/usr/local/ to install in /usr/local which is
designed for locally-installed software.
I was trying to resolve the problem for python3 in MacOS. The accepted answer didn't help me.
What helped me is complete reinstall of the python3:
brew uninstall python3 # if python3 worked before
brew install python3

Old version of python 3.4 not allowing python 3.6.5 to work

I'm trying to upgrade the version of python on my Mac using homebrew. I do brew install python3 and I see that it installs python 3.6.5. However, when I do python3 --version I get -bash: /Library/Frameworks/Python.framework/Versions/3.4/bin/python3: No such file or directory. Not sure how I'm suppose to resolve this. Someone posted something similar (Unable to Run Python 3 After Homebrew Installation) but the solution is to download another version of python from the website, but I don't think this solves the fundamental issue of this lingering version. Any idea how I can resolve this?

Issues locating the right python

First of all, I should say that I am not a python expert.
I am struggling with different versions of python installed in my OS. I am running python v2.7 but after an update via brew, I got an issue. When I run a package called ilamb, I get the following error:
/usr/local/bin/ilamb-run: bad interpreter:
/usr/local/opt/python/bin/python2.7: no such file or directory
The computer is somehow looking at local/opt folder, which I suspect was created from macports. I unfortunately deleted this folder because I was trying to standardize installations via brew and/or pip to avoid the kind of errors I am struggling with now. However, my python version is located at:
which python
/usr/bin/python
How can I point to the right location?
Try installing ilamb again using
python -m pip install ILAMB
Believe you used sudo for installation which might have caused this. Try this below:
brew install python
brew linkapps python
brew link --overwrite python

Install Python 3 alongside Python 2 problematic?

My programming literacy is very basic, but I like programming and I have been taking some MOOC's to bring me into the 21st century.
I started off by taking a course in Python and installed 2.7.11 (from https://www.python.org/downloads/), now I am onto another course that requires Python 3.x
Can I simply install Python 3.x alongside the 2.x version (on my Mac)? Or, will that create all kinds of conflicts and problems? To add to the picture, I am just using the IDLE that comes along with the download.
If the solution involves a bunch of terminal line commands, or coordinating 3 additional downloads of other packages to make it happen, it is already out of my league. Like I said, I am coming into this as nearly a complete novice.
Thanks for you help.
This might help anyone having Error: python 2.7.14 is already installed when trying to install python3 with brew install python3. Due to python2.7 being retired on 2020, python3 is now the same as python and python2 is python#2.
To fix the error, just run brew upgrade python and if you still want python2 you can install it by brew install python2. In my case I did not have to run the final command and I had both python installed.
It shouldn't create any conflicts simply install python3 with brew install python3, also you get more info for doing it correctly in What is the correct way to install python on OS X? question.
NOTE: After installing python3 you would have two python interpreters python3 and python2.7, your python points to python2.7 as long as you don't change it, in other words your default python interpreter is python2.7 and do not change it without serious reason for that.
To run python3 scripts execute them with your python3 interpreter, tools like pip, easy_install, virtualenv for python3 shall be installed with that interpreter (python3).
You might want to look into pyenv: "pyenv lets you easily switch between multiple versions of Python". Also install-able with brew install pyenv
If you like programming you had better get used to doing a bit of setup and juggling of downloads. If you are going to do much python for different projects you would do well to understand virtualenv's before you find your projects' requirements conflicting.

pip: command not found (OS X) - editing bash_profile doesn't work

I have installed Python 2.7 on Mac and installed pip (with the eventual goal of installing python-swiftclient: https://www.swiftstack.com/docs/integration/python-swiftclient.html )
Unfortunately I get the error "command not found" on using pip.
I have followed the instructions in this thread: pip: command not found I added export PATH=${PATH}:/Library/Python/2.7/site-packages (I verified that this is the correct path) to .bash_profile and ran the source command.
Pip is still not being found.
Anyone know a solution? (Keep in mind this is my first foray into installing python and doing command line stuff. I'm not a born unix user so installing packages and such is pretty new to me...)
Thanks!
When I use python on Mac, I simply install Anaconda, which is shipped with pip. So maybe you could use that.
Anaconda
Try using python -m pip until you get this resolved (or forever if you want :P)

Categories