Relatively new developer here, and this is my first time posting. For two days I have been searching for the answer to the issue I have been having, following guides and such but I seem to keep digging myself into a deeper hole with this one. So I decided to post here for help
What is happening is it appears that I have python installed properly, but when I run echo $PATH in terminal I get this:
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/python3
I have tried editing the ~/.bash_profile to make sure that the correct path is listed, and currently it appears as:
/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}
I'm assuming that having the ${PATH} there may be what's causing it to continuously echo as it is, but I'm not sure about removing anything since I don't want to screw things up.
Also when using sublime text 3 I can't get similar errors, I'm assuming because it's not correctly finding the path. I'm not able to build until I can find a way to resolve this, but for the moment at least I am at a loss.
Any help would be greatly appreciated!!!
Install Homebrew and then install python with brew install python
See if you have python installed with brew by ll /usr/local/bin/python*
/Library/Frameworks/Python.framework/Versions/3.6/bin part in your path is duplicated. Remove them and keep your path as /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/python3
Seems like you downloaded Python 3 from python.org. You should uninstall and use homebrew.
Uninstall whatever you downloaded from python.org by replacing 2.7 with 3.6 in these instructions. This should fix your path. From now on, don't mess with it (leave ~/.bash_profile empty). Homebrew handles that.
Reinstall Python with homebrew brew reinstall python, I would personally install with tcl-tk: brew reinstall python --with-tcl-tk which will make idle3 run without warnings.
Related
I'm installing a bunch of python modules on my system that are specific to this code I am going to be working with. Specifically, I used pip install pyda to get the pyda module. To make sure I had gotten all the modules, I went through and ran some of the code snippets, and came across the following error:
ModuleNotFoundError: No module named 'pyda.utilities'
I tried using pip install pyda.utilities, but that honestly doesn't make sense, it should have just come with the pyda module. According to this website https://pypi.org/project/pyda/ it seems like it should come with the package. I tried determining if I just installed it in the wrong python version, but I'm having a difficult time forcing it to use the specific python version that I installed the module in (specifically, I tried to create an alias for /usr/bin/python3.7 or something like this as I have seen on other websites, but it just fusses at me that this is simply a directory, incredibly unhelpful because I can't find the corresponding executable, so I'm a bit confused here).
This is a very long question likely with a very simple answer, any thoughts or help on what the issue might be would be appreciated.
Edit: I have determined that it's a package problem, not a python problem. The command 'pip install pyda' is not actually installing everything, oddly enough, which is why it cannot find the pyda.utilities module. Unfortunately, I think this means I will have to install the package manually. I will keep this question posted because of the useful answer on virtual environments, so thanks everyone.
The answer is indeed straightforward. As #Chris indicated in the comments, start using virtual environments.
It's not as complicated as it sounds and there's plenty of tutorials on getting started with virtualenv for Python, like https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/26/python-virtual-env/
The basic steps:
check you're using the version of Python you want in your virtual environment
if you don't, change directories to where it lives
ensure you have pip and it works
check if you have virtualenv and if you don't pip install virtualenv
create a virtual environment virtualenv /your/env/folder/here
activate the virtual environment with /your/env/folder/here/Scripts/activate
After that, just install the packages you need with pip and they will end up in your virtual environment, with no interference from other Python versions or packages.
Check your python version, if it does not work restart your computer and try run setup.py install on the python command line
I had python2 installed on my macOS and I parallel installed python3 (without homebrew). It worked perfect and I could use python3 and pip3 from every directory without problems parallel to python and pip for version 2.
Some days ago I did not find pip3 and I had to set an alias to python3 -m ... (I thought I didn't use it before but I had!). Today in the morning I worked with python3 without problems and now python3 got a command not found but I cannot find it on my directories, too.
Where is my python3? And why it is gone?
The only reason I see is that I installed homebrew about a week ago for installing mutt. Is it possible that the brew upgrade function has destroyed paths or even installations?
Would be great to get help from you!
Thanks a lot.
Maybe someone else has the same problem. Therefore the steps for my solution:
the which command shows me the directories of the versions linked everywhere in the system
the argument --version gave me an overview of where I found the different versions of python and vim (for more informations about the directory-changes I checked vim, too)
looking at echo $PATH and ls -lha /etc/paths* I knew more about the current sequence of possible directories of installations and about changes (brew saved the original file as /etc/paths~orig)
with these informations I first upgraded with brew upgrade python3 (it seems that my installed libraries stayed like in the days before the mysterious loss of python3), then I could change the paths and add some alias to get the environment I want to work with
Now everything seems to be like before the problems. If I will notice any further changes I now have the knowledge to solve them within some minutes. Good feeling!
It's not solved why brew downgraded the python3-installation because I'm sure not having installed it in the days of adding python3 to python2. But that isn't very important.
Thanks to the helpers - especially #avigil.
I had the same strange behavior after a brew upgrade: python 3 suddenly disappeared.
brew install python3
told me that
python 2.7.14 is already installed
To upgrade to 3.6.5, run `brew upgrade python`
So that is what I did. The homebrew install of python 2 is gone now, but can be installed again using brew install python#2 .
In case this helps, I had a similar problem where a homebrew upgrade made python3 seem to disappear.
brew install python3
...told me python3 was already installed and just needed to be linked with
brew link python
Ran it, and the symlinks it created seem to have resolved the issue.
I think i somehow messed up installing packages for python and the whole environment. Whenever i want to install something i run into problems like:
directory is not owned by the current user and the cache has been disabled
Also PyCharm thinks i still need to install referenced packages (no modules. Which is wrong since i can use them. When i click on 'install referenced packages' i get the mentioned warning from above plus:
OSError: [Errno 1] Operation not permitted
Hopefully one of you can help! :(
Best regards
Matthias
Edit: At some point i also installed a venv for python. Maybe this relates to my problem. I'm rly sorry i am new to it and have no idea what i'm doing.
You have an issue with your permissions, if you run
which python
you will see where your current version of python is installed. If you're on osx, I seriously recommend downloading brew here: https://brew.sh/. Just paste that command into your terminal, then you should install python by running:
brew install python
This will give you some later instructions, but the brew bundled version of python is alot more robust than the one that gets bundled with your system. Another note is that if you're using virtual environments, consider using virtualenvwrapper here. This should make things run alot more smoothly for you :)
Hope that helps.
My python installation is a mess.
Therefore I'd like to reinstall the entire installation of it. (Unfortunately,) I've also installed QGIS and PyCharm (mostly making it a mess) and I want to start clean..!
So, what is the best way to get rid of every little python thingy and what are the best packages/methods for reinstalling Python27, QGIS and PyCharm? Should I go for osgeo or not, should I first install Pycharm or Python etc. Hopefully you have some good thoughts and tools on this. I'm a fan of pip, so in the end I hope its possible just to use pip for installing the packages all around.
I'm working on Windows 7, 64bit (thanks for the headsup Karel)
Go to add/remove programs in windows and uninstall everything. Then reinstall everything. Do your Python install first and PyCharm should detect everything. I'd suggest doing the 32 bit Python install as some packages aren't compiled for 64 bit and it makes things a bit challenging to find and install them.
Pip is standard in the python install now. You'll see a check box in the installer for it, which is pre-checked. I'd change your install directory to something simple like C:\Python27
Other than that it should be pretty straightforward. However I doubt you really need to uninstall Python. You can just go to settings and under the interpreter section add the C:\Python27 directory. PyCharm is constantly scanning for installed modules, so it will know in real time that you've installed them. You can even install packaged via PIP while PyCharm is open and within second PyCharm will recognize it as a valid package.
If you're missing packages you can also import them in PyCharm and when you get the red underline saying it's missing, hover your mouse over it and hit alt+enter and you'll get a menu to install it.
I have installed Python using Homebrew. I would like for this installation of python to recognize only one site-pakages directory -- /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
However, when I start the python shell and give the command print [f for f in sys.path if f.endswith('packages')] I get the following output:
['/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']
Why is /Library/Python/2.7/site-packages sitting at the end there? Shouldn't the Homebrew installation of Python have just one main site-packages directory under /usr/local/ ???
Edit: I am using virtualenv -- but this is occurring after a fresh install of python using homebrew before I have even had a chance to install virtualenv. Also, I'm interested in why it is happening, not on what I should do to get around it.
Created a stack overflow account just for this, since I was so annoyed by it. I actually had a bug inadvertently caused by that extra "/Library/Python/2.7/site-packages" in the sys.path
Researching it led me to this:
http://bugs.python.org/issue4865
tl;dr: From what I can tell, they throw that path in there to help people that installed packages for the apple-shipped python, but then later would try to use those packages in other versions of python (like the ones used by homebrew, macports, etc).