brew trying "migrating python3 to python" every time - python-3.x

I believe the python environment is my Mac is a little bit mess up...
Every time I use brew, it will first do this:
==> Migrating python3 to python
==> Unlinking python3
==> Unlinking python
Error: Error occurred while migrating.
Permission denied # unlink_internal - /usr/local/share/python
Backing up...
Error: Permission denied # unlink_internal - /usr/local/share/python
in my mac, I have:
python2, which is referred by 'python', and it's installed by
anaconda bundle.
python3, which is referred by 'python3', and it's
installed by brew.
Actually I create a symbolic link in /usr/local/bin for python3, which is the best way I can figure out to distinguish python/python3 in my machine......but recently it's just messed up...
I tried find / -name "python3", and here is the result:
/Users/liuziqi/anaconda/lib/python2.7/site-packages/astroid/tests/testdata/python3
/Users/liuziqi/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/crcmod/python3
/Users/liuziqi/google-cloud-sdk/.install/.backup/platform/gsutil/third_party/httplib2/python3
/Users/liuziqi/google-cloud-sdk/platform/gsutil/third_party/crcmod/python3
/Users/liuziqi/google-cloud-sdk/platform/gsutil/third_party/httplib2/python3
/usr/local/Cellar/python3
/usr/local/Cellar/python3/3.6.1/bin/python3
/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/Cellar/python3/3.6.4_2/bin/python3
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/python3
/usr/local/lib/python3.6/site-packages/astroid/tests/testdata/python3
/usr/local/opt/python3
the python3 I previously used is /usr/local/Cellar/python3/3.6.1/bin/python3, and I created a link to /usr/local/bin

You have to fix the permissions with:
sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew
It works well, if you are the only Homebrew user on the system. It could cause problems if third party tools are waiting other permissions on /usr/local. But, I use this settings for years without problems. See How to fix homebrew permissions? for details.

Related

Unable to create environments file. Path not writable. Mac M1 Chip python modules

Hi I'm trying to install TensorFlow for MAC M1 Chip OS 12.0. Post installing the application and trying to install numpy and Jupiter notebook using the below command
conda install notebook - y
conda install -c conda-forge numpy -y
I get the error
Unable to create environments file. Path not writable.
environment location: /Users/ren/.conda/environments.txt
done
Executing transaction: | WARNING conda.core.envs_manager:register_env(50): Unable to register environment. Path not writable or missing.
environment location: /Users/ren/miniforge3
registry file: /Users/ren/.conda/environments.txt
I went to the folder and changed the permissions of the file manually it did not work
I ran the command 775 /.conda/ from the terminal it did not work. I removed all the folders for anaconda and Miniforge multiple times I get the same error.
Any suggestions how to get this to work?
Regards,
Ren
sudo chmod -R 775 /Users/Ren/.conda Worked for me after trying multiple solutions.
I solved this by manually chmoding the file path.
sudo chmod 775 /Users/michaelmoreno/.conda/environments.txt

Updating nodejs with homebrew dilemma: need more permission but brew doesn't work with sudo?

I am trying to update node from 10 to 12 on my mac 11.6 (20G165).
And I would like to use the homebrew way:
brew upgrade node
However, after running this, I got:
$ brew upgrade node
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7
Well, then I tried the sudo way:
sudo brew upgrade node
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
What should I do to fix it now?
Can I just grant the
/usr/local/share/man/man5
/usr/local/share/man/man7
directories to my current user? Is there any risk by doing so?
My homebrew version:
Homebrew 3.2.17
Homebrew/homebrew-core (git revision 0e79905a9e5; last commit 2021-10-20)
Well I had a same problem, and solved it by commands provided which were followed by error.
sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7

uninstall Python3 downloaded from command line tools

I installed python 3.8.2 using xcode command line tools but now according to this article I should remove it to download Miniforge3. I didn't know how to do it so now I encountered this error when I ran command
file $(which python)
architecture error
According to the article and some online sources, it should only show arm64 but mine showed arm64e. When I navigated to condabin folder and try running conda init it crashed.
I think I should remove Python3 and start Miniforge installation process again, but I don't know how to delete it. I tried
sudo rm -rf /usr/bin/python3
but it said: Operation not permitted

installed python 3x on mac but terminal still show version still 2x

I installed python 3x via home brew, the process was successful.
However when I check version, it shows 2x
here is the terminal output
➜ ~ brew install python
Warning: python 3.7.2 is already installed, it's just not linked
You can use `brew link python` to link this version.
➜ ~ brew link python
Linking /usr/local/Cellar/python/3.7.2... Error: Permission denied # dir_s_mkdir - /usr/local/Frameworks
➜ ~ sudo brew link python
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
➜ ~ python -V
Python 2.7.10
I think I need to modify some kind of path. And do some magic then pray...lol
Anyway anyone know how to get this work on my machine? I'm mac latest
First, solve your permission problem by running the official command from the Homebrew Documentation, Troubleshooting page
cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var opt Cellar Caskroom Frameworks
Then run brew link python
And finally run echo $PATH and check that your /usr/local/bin has precedence over other directories.
you could do brew uninstall python3 and install it from the python website here https://www.python.org/
When you go install a module you do pip3 install packageName
And when you run a program you could run it from your IDE (I recommend VSCode) or run it from the terminal with python3 drag_python_file_here
you have to use python3 instead of python on Mac so like python3 path/to/file.py and pip is now pip3 so like pip3 install pillow

Can't find Python.h when compiling PyCaffe on Ubuntu 14.04

I'm trying to install PyCaffe for Python 3.5.3 on AWS EC2 with Ubuntu 14.04 without Anaconda, following the installation instructions.
I successfully compiled it on the same machine for Python 2.7 but when compiling for version 3.5 I get the following error:
ubuntu#ip-172-31-3-227:~/caffe$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory
#include <Python.h> // NOLINT(build/include_alpha)
I saw this post and performed:
sudo apt-get install python3-dev
I found this, so I performed the equivalent command for Python 3.5:
for req in $(cat requirements.txt); do sudo pip3.5 install $req; done
All installations worked but it didn't fix the problem.
I many other posts on similar problems but not this exact problem (so if you find something please check that it's really the same situation before rushing to say I didn't look well enough).
P.S.
I also saw this post but I don't understand which directories to add to the path.
When you do a pip install package,when pip finds new version,it uninstall the current one(dateutil in your case) when the package was installed using certain permission,pip needs the same permission to uninstall/upgrade it.
A quick fix would be to change this
`for req in $(cat requirements.txt); do pip3.5 install $req; done` to
for req in $(cat requirements.txt); do sudo pip3.5 install $req; done
It seems you dont have permission to access /usr/local/lib/python3.5/ folder as user,the packages that goes in /usr/local are required by the system but only available to you and only you on the system, i assume since only only they are restricted to you and pip want to access assuming that no restriction is there,then it get permission denied ,so you might consider doing
for req in $(cat requirements.txt); do pip3.5 --user yourusername install $req; done
the alternative is to remove any restriction to execute and write on that folder
by doing chmod -R 777 /usr/local/lib/python3.5/ which is usually not recommended but the problem you need pip to be able to read,write,execute anything in that folder.

Resources