I have uninstalled python3 using brew on macOS Catalina 10.15.3:
brew uninstall python3
brew list | grep python
python#2
But it still there:
which python3
/usr/bin/python3
python3 -V
Python 3.7.3
/usr/bin/python3 -V
Python 3.7.3
ls -ltah /usr/bin/ | grep python
-rwxr-xr-x 1 root wheel 31K Jan 23 16:58 python3
lrwxr-xr-x 1 root wheel 75B Dec 16 06:20 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82B Dec 16 06:20 python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 root wheel 76B Dec 16 06:20 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x 1 root wheel 82B Dec 16 06:20 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 root wheel 76B Dec 16 06:20 pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x 1 root wheel 75B Dec 16 06:20 python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 75B Dec 16 06:20 python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
It's interesting but on error it shows different location of python:
python3 -bla
Unknown option: -l
usage: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
Seems it's related to Xcode.
How to delete this version python3 and reinstall python using brew?
Update:
sudo rm -f /usr/bin/python3
rm: /usr/bin/python3: Operation not permitted
Catalina comes with python3 installed by default**. You can't delete it, because /usr/bin is on the System's read-only volume.
If you install your new python to a bin folder that comes before /usr/bin in your $PATH, then it should take precedence.
** (Well OK, the first time you run it, you have to install Xcode command line tools to make it work. But that file itself is a system install.)
Related
I have python 3.10 installed. But I am trying to use a python script which is only compatible with python 3.9.
So I have installed 3.9.
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar -xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure
sudo make altinstall
Python 3.9 is now installed, so I have bother 3.9 and 3.10 installed.
When I search how to use 3.9 most results say to delete 3.10.
Is there an option to temprarily switch to 3.9? So after can switch back to 3.10?
Thanks
When you have:
$ ls -l /usr/bin/python3.10
-rwxr-xr-x 1 root root 5921160 Nov 14 17:10 /usr/bin/python3.10
$ ls -l /usr/local/bin/python3.9
-rwxr-xr-x 1 root root 15651728 Dec 31 15:58 /usr/local/bin/python3.9
Then you can do:
sudo update-alternatives --install /usr/bin/python3 python /usr/local/bin/python3.10 0
sudo update-alternatives --install /usr/bin/python3 python /usr/local/bin/python3.9 0
After this being done, this should work:
$ python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3.10 0 auto mode
1 /usr/bin/python3.10 0 manual mode
2 /usr/local/bin/python3.9 0 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/local/bin/python3.9 to provide /usr/bin/python3 (python) in manual mode
$ python3
Python 3.9.0 (default, Dec 31 2022, 15:24:44)
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
$
After the update-alternatives process, you should find this link:
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 24 Dec 31 16:17 /usr/bin/python3 -> /etc/alternatives/python
and in '/etc/alternatives' a link, named python which points to:
python -> /usr/local/bin/python3.9
or
python -> /usr/bin/python3.10
NOTE: You need to do the same for pip (or pip3), and other tools that relate to python3
I try to set up FastRTPS inside a docker container. I wrote a Dockerfile which builds FastRTPS and it's dependencies from source and installs the libraries and delivered examples. But the examples do not work:
/opt# /usr/local/examples/C++/HelloWorldExample/bin/HelloWorldExample
/usr/local/examples/C++/HelloWorldExample/bin/HelloWorldExample: error while loading shared libraries: libfastrtps.so.1: cannot open shared object file: No such file or directory
As these library was built in this container and automatically installed, it must be somewhere and they are here:
root#6e544f0699cf:/opt# ls -la /usr/local/lib/
total 9196
drwxr-xr-x 1 root root 4096 Mar 26 22:02 .
drwxr-xr-x 1 root root 4096 Mar 26 22:02 ..
drwxr-xr-x 3 root root 4096 Mar 26 22:00 cmake
drwxr-xr-x 3 root root 4096 Mar 26 22:00 foonathan_memory
lrwxrwxrwx 1 root root 15 Mar 26 22:00 libfastcdr.so -> libfastcdr.so.1
lrwxrwxrwx 1 root root 20 Mar 26 22:00 libfastcdr.so.1 -> libfastcdr.so.1.0.12
-rw-r--r-- 1 root root 99504 Mar 26 22:00 libfastcdr.so.1.0.12
lrwxrwxrwx 1 root root 16 Mar 26 22:02 libfastrtps.so -> libfastrtps.so.1
lrwxrwxrwx 1 root root 21 Mar 26 22:02 libfastrtps.so.1 -> libfastrtps.so.1.10.0
-rw-r--r-- 1 root root 8133952 Mar 26 22:01 libfastrtps.so.1.10.0
-rw-r--r-- 1 root root 1158048 Mar 26 22:00 libfoonathan_memory-0.6.2.a
drwxrwsr-x 3 root staff 4096 Mar 26 21:37 python3.7
It is also possible to look into this library # nm -D /usr/local/lib/libfastrtps.so.1.
But the output of ldconfig is a bit strange:
# ldconfig -v | grep /usr/local/lib
ldconfig: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
ldconfig: Path `/lib/x86_64-linux-gnu' given more than once
ldconfig: Path `/usr/lib/x86_64-linux-gnu' given more than once
ldconfig: /lib/x86_64-linux-gnu/ld-2.28.so is the dynamic linker, ignoring
/usr/local/lib:
Here I expected the libraries listed but they are not.
How to fix that?
EDIT 1
some extractions from the make output while building FastRTPS:
...
-- Installing: /usr/local/lib/libfastrtps.so.1.10.0
-- Installing: /usr/local/lib/libfastrtps.so.1
-- Installing: /usr/local/lib/libfastrtps.so
...
-- Installing: /usr/local/examples/C++/HelloWorldExample/bin/HelloWorldExample
-- Set runtime path of "/usr/local/examples/C++/HelloWorldExample/bin/HelloWorldExample" to ""
Why the runtime path is set to "" - nothing?
The last edit led to the issue and also to the solution.
CMake removes the RPATH. In case of the usage within a docker container, this stripping makes no sense and can be turned off as described in this post by adding this argument to the CMake configuration call:
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
At the end my Dockerfile looks like this:
FROM fastrtps-core
WORKDIR /opt
RUN git clone https://github.com/eProsima/Fast-RTPS.git && \
export LDFLAGS="-Wl,--copy-dt-needed-entries" && \
mkdir build && \
cd build && \
cmake ../Fast-RTPS/examples \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE && \
cmake --build . --target install -j 16 && \
cd /opt && \
rm -rf build Fast-RTPS
Now the install-step output shows the correct runtime-path setting:
-- Installing: /usr/local/examples/C++/HelloWorldExample/HelloWorldExample
-- Set runtime path of "/usr/local/examples/C++/HelloWorldExample/HelloWorldExample" to "/usr/local/lib"
When executing a Python 3 script in a symbolic directory, I want to get the non-dereferenced path of the current directory. However, the default behavior of pathlib returns the derefenced path:
$ mkdir test1
$ ln -s test1 test2
$ cd test2
$ pwd
/home/myuser/test2
$ ipython3
Python 3.7.0 (default, Oct 9 2018, 10:31:47)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from pathlib import Path
In [2]: str(Path.cwd())
/home/myuser/test1
The behavior I want is to get "/home/myuser/test2" as that's where the 'script' (interpreter in this case) was executed from, preferably using pathlib.
Use os.getenv('PWD'):
Directories:
$ ls -l
total 1
drwxr-xr-x+ 1 cody agroup 0 Dec 11 15:23 dir1
lrwxrwxrwx 1 cody agroup 4 Dec 11 15:23 dir2 -> dir1
Result from dir2:
>>> str(Path.cwd())
'/home/cody/so/dir1'
>>> os.getenv('PWD')
'/home/cody/so/dir2'
I am trying to run Quartus 13.0 in the following machine:
parrot 4.18.0-parrot10-amd64 #1 SMP Debian 4.18.10-1parrot10 (2018-10-06) x86_64 GNU/Linux.
I have finished installing Quartus 13.0 and when I try to execute it I get this error:
quartus: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
I have read all the related questions in stack overflow and other websites but no one worked for me.
When looking for that file, I found it. I have tried to do a hard link but it doesn't work either. Search results:
┌─[pepbd#parrot]─[~]
└──╼ $ls -ld $(locate -r libpng.*\.so.*)
lrwxrwxrwx 1 root root 19 nov 19 17:09 /usr/lib/x86_64-linux-gnu/libpng16.so.16 -> libpng16.so.16.34.0
-rw-r--r-- 1 root root 210864 jul 10 13:17 /usr/lib/x86_64-linux-gnu/libpng16.so.16.34.0
-rw-r--r-- 1 root root 18272 oct 14 21:59 /usr/lib/x86_64-linux-gnu/vlc/plugins/codec/libpng_plugin.so
I had the same problem with Quartus Prime 18 on Ubuntu. This worked for me (run as sudo):
wget -q -O /tmp/libpng12.deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1_amd64.deb \
&& dpkg -i /tmp/libpng12.deb \
&& rm /tmp/libpng12.deb
Earlier this afternoon I installed Node.js on Fedora 16.
user#$ sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/fedora/nodejs-stable-release.noarch.rpm
user#$ sudo yum install nodejs-compat-symlinks npm
Then I installed a package with npm. Every package I've installed with npm on Fedora (this isn't my first time) has involved something like the following process. Read it and weep. Clearly, this is hackish and wrong, but when I decide to install less or any other npm package, I have to go through the same procedure. Why? What is broken about my environment or approach?
user#$ sudo npm install -g jslint
[... this works ... kind of]
user#$ jslint
bash: jslint: command not found
user#$ sudo su
root#$ jslint
No files specified.
Usage: /bin/jslint ... [works]
root#$ which jslint
/bin/jslint
root#$ ls -l jslint
lrwxrwxrwx. 1 root root 38 Jul 15 14:58 /bin/jslint -> /lib/node_modules/jslint/bin/jslint.js
root#$ cd /lib/node_modules; ls -l
...
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 inherits
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 ini
drwx------. 6 nobody usergroup 4096 Jul 15 14:58 jshint
drwxr-xr-x. 3 root root 4096 Jul 15 14:22 lru-cache
...
root#$ find . -type d -print0 | xargs -0 chmod 755
root#$ ls -l
...
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 inherits
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 ini
drwxr-xr-x. 5 nobody usergroup 4096 Jul 15 15:32 jslint
drwxr-xr-x. 3 root root 4096 Jul 15 14:22 lru-cache
...
root#$ su user
user#$ jslint
o files specified.
Usage: /bin/jslint [now it finally works]
Recent versions of npm switch to user "nobody" as a security measure if it's being run with sudo privileges. Try doing global installs while logged in as root, rather than using sudo.