I messed up my conda installation and now there is no file named python in anaconda3/bin directory.
$ conda info -a
/home/username/anaconda3/bin/conda: line 2: /home/username/anaconda3/bin/python: No such file or directory
$ which python
/usr/bin/python
$ python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
When I enter the anaconda3/bin directory I can see the following files:
$ ls | grep python
ipython3.c~
ipython.c~
python3.9.c~
python3.9-config.c~
python3.c~
python3-config.c~
python.c~
I want to uninstall conda and start over but I can not use conda to install anaconda-clean with which I could uninstall conda. How can I uninstall conda completely to get rid of all inconsistencies and problems I created?
Related
I can confirm I installed python3.8
brew install python
Warning: python#3.8 3.8.5 is already installed and up-to-date
To reinstall 3.8.5, run `brew reinstall python#3.8
However, macOS still points to python3.6
$python --version
Python 3.6.8 :: Anaconda, Inc.
$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
What's the workaround to point to version 3.8?
Pretty certain the simple fix here since your path is small is to get rid of the
/anaconda3/bin and /Users/Sani/anaconda3/bin in your PATH variable.
Try this:
export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/anaconda3/bin" | tr "\n" ":"); echo ${p%:})
We are taking whatever is inside the grep command and removing it
export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/Users/sani/anaconda3/bin" | tr "\n" ":"); echo ${p%:})
You may need to restart your terminal to see if it changed. I assume the Python3.6 is being picked up through the Anaconda bins.
Otherwise yes uninstalling Anaconda3 will solve your problem.
I have found a way out
conda install python=3.8
works for me.
$ python
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
1, I had a new linux with python=python2.7 and python3=python3.4
2, I installed pyenv by using git
3, I installed anaconda3-4.1.1 by using pyenv and set it as global via pyenv by using pyenv global anaconda3-4.1.1
4, I created a virtualenv by using pyenv virtualenv anaconda3-4.1.1 mytestenv
5, I use import numpy to test the result. In the original anaconda3-4.1.1 env it's OK for importing numpy, but in the mytestenv env there is no numpy.
Please see the details following:
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv versions
system
* anaconda3-4.1.1 (set by /home/giza/.pyenv/version)
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv virtualenv anaconda3-4.1.1 mytestenv
Fetching package metadata .......
Solving package specifications: ..........
Package plan for installation in environment /home/giza/.pyenv/versions/anaconda3-4.1.1/envs/mytestenv:
The following NEW packages will be INSTALLED:
openssl: 1.0.2j-0
pip: 8.1.2-py35_0
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-0
zlib: 1.2.8-3
Linking packages ...
[ COMPLETE ]|##########################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate mytestenv
#
# To deactivate this environment, use:
# $ source deactivate
#
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Requirement already up-to-date: pip in /home/giza/.pyenv/versions/anaconda3- 4.1.1/envs/mytestenv/lib/python3.5/site-packages
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv activate mytestenv
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(mytestenv) giza#DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> exit()
(mytestenv) giza#DESKTOP-H8KC9QC:~$ pyenv deactivate
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> exit()
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$
I am a non-superuser of a linux machine.
Currently it has 2 versions of Python.
When I invoke standard python command it gave version 2.6
$ python
[neversaint#mach71 ~]$ python
Python 2.6.2 (r262:71600, Jan 28 2011, 13:47:39)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ which python
/opt/somedir/bin/python
It's only when I invoke with python2.7 it gives the version 2.7
[neversaint#mach71 ~]$ python2.7
Python 2.7.6 (default, Nov 11 2013, 13:13:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ which phython2.7
/usr/bin/python2.7
My question is how can I set it such that whenever I call $ python it will give me version 2.7.
You can simlink it into some directory both accessible to your user and in your $PATH. For example if /home/<your-username>/local/bin is in your $PATH then you can do
ln -s /usr/bin/python2.7 /home/<your-username>/local/bin/python
In this example /home/<your-username>/local/bin should be in your path before /usr/bin. If there is no such entry in your $PATH you can add it there:
export PATH=$HOME/local/bin:$PATH
You can also add this line to .bashrc or similar to activate it on shell start.
Use a shell alias, alias python=/usr/bin/python2.7 and then python will execute the result of that alias.
in /usr/bin create symlink to python27 or whatever python version you have
sudo ln -s python2.7 python
I'm trying to use a newer Python (2.7.3) with an old CentOS.
I have a recipe to install python to a non-standard location:
./configure --prefix=#{install_path} --with-threads --enable-shared --with-zlib=/usr/include
make
make install
I set the PATH and LD_LIBRARY_PATH variables to find bin/python and the .so files using /etc/profile.d/. This seems to mostly work.
With a non-root user, I get the right Python:
[vagrant#localhost ~]$ python
Python 2.7.3 (default, Dec 24 2012, 15:18:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
With a root user, I get the right Python:
[vagrant#localhost ~]$ sudo su
[root#localhost vagrant]# python
Python 2.7.3 (default, Dec 24 2012, 15:18:59)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
However, the $LD_LIBRARY_PATH hack seems to be a little wonked when using sudo:
[vagrant#localhost ~]$ sudo python
python: error while loading shared libraries: libpython2.7.so.1.0:
cannot open shared object file: No such file or directory
Even though the variables look right:
[vagrant#localhost ~]$ sudo which python
/opt/Python-2.7.3/bin/python
Adding Defaults env_keep += "LD_LIBRARY_PATH" to /etc/sudoers does not work.
sudo -i python does work.
sudo -E python does not work.
I'm curious what I could do to get sudo to pick up the right Python without -i?
related:
sudo changes PATH - why?
https://stackoverflow.com/questions/12593336/odd-path-behaviour-on-centos-python
Thanks to this blog post. You can forego the use of $LD_LIBRARY_PATH by linking with LDFLAGS in configure. Where #{ldlibpath} is #{install_path}/lib:
./configure --prefix=#{install_path} --with-threads --enable-shared \
--with-zlib=/usr/include LDFLAGS="-Wl,-rpath #{ldlibpath}"
As noted in the blog post, you will need to mkdir this ldlibpath before running configure.
I am trying to install setuptools via an egg on my VPS. However, I keep getting an error that Python2.6 doesn't exist despite the fact that it is in $PATH:
[root#host install]# sudo sh setuptools-0.6c11-py2.6.egg
setuptools-0.6c11-py2.6.egg: line 3: exec: python2.6: not found
[root#host install]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/wt_python/bin
[root#host install]# sudo /usr/local/wt_python/bin/python2.6
Python 2.6.5 (r265:79063, May 18 2010, 16:49:22)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root#host install]# sudo python2.6
Python 2.6.5 (r265:79063, May 18 2010, 16:49:22)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Any idea what could be wrong?
Thanks
1 ) sudo as root is redundant.
2 ) for a quick hack symlink your python install into a standardized path. I'm not 100% familiar with the setuptools installer, but it could spawn a subshell that would mess with environment variables. For that matter sudo depending on flags messes with environment variables.
3) If there isnt a reason why you specifically need a custom python build why not use the one in the repositories?
Hope one or a few of the ideas help.
Rob