Accidentally installed python 3.5 vs. python3.5 : Is this bad? - python

I run Linux Mint with Python 3.4.x pre-installed. I'm starting a new project and wanted to take advantage of 3.5ish stuff so I decided I would install 3.5 and create my new virtual environment pointing to it.
So, I by accident typed
sudo apt-get install python 3.5
Which I've since learned is different from
sudo apt-get install python3.5.
I know that is different because the later requires adding a new repository wherein the former I was able to do before I added the deadsnakes repo.
So, I went through the install of "python 3.5" - it asked me some questions about FTP to ined(something) or standalone, then I installed python3.5.
My question(s) is
1) What is python 3.5? (with the space),
2) Did I break anything,
3) Should I uninstall python 3.5 even though the uninstall warns me not to unless I really know what I am doing?
Thank you

Newer versions always have newer patches and fixes. Python 3.5.2 is probably what you installed if you used sudo apt-get install python3.5. There is also Python 3.6 now.
With the space (sudo apt-get install python 3.5) it would mean install python and 3.5 so maybe it just installed/updated python2.
Anyway, having multiple versions is not an issue. You may alias each install and use them as required.
Should I uninstall python 3.5 even though the uninstall warns me not to unless I really know what I am doing?
You shall do that if no other program/dependency is lost. Have you used it in some code? (which wouldn't work if its gone!) If you haven't then go ahead uninstall it.

It's not good. I had the same installing Ruby and accidentally typing:
Don't do this!!
apt install ruby 2.4
It installed the latest Ruby and many gigabytes of packages with 2.4 in the name.
I tried to remove them with
apt remove 2.4
...but it turns out some of these packages are essential for the Operating System.
To list the packages with label 2.4:
apt-cache show 2.4
So uninstalling non-essential packages could be an option if you manage to list them and use that output as arguments for apt remove. But I suppose even then your system may potentially be left unstable.
Luckily I ran the command on a relatively fresh Raspbian install so I'll just do a clean install. Apt install is a surprisingly dangerous command, :D, good luck

Related

How to install python 3.8.12 on /usr/bin/python?

I want to install python 3.8.12 on my ubuntu .
I followed this link: https://tecadmin.net/install-python-3-8-ubuntu/ and installed python in my Download folder and I can't find it at /usr/bin/python3.8.12
Is it right that all the python versions need to be found at /usr/bin ?
Do I need to copy it manually to /usr/bin ?
Is there a way I can install python 3.8.12 with apt-get ?
That article is outdated, most likely written at a time where Python 3.8 was not yet available on the stable Ubuntu repositories.
You can install the latest Python available with just apt install python3 (3.9 at the moment).
If you really want 3.8, I suggest you take a look at the deadsnakes PPA. It contains an archive of all Python packages for Ubuntu, and also newer versions that haven't hit Ubuntu stable yet (like 3.10).
You can add this PPA and install Python 3.8 with just three commands:
add-apt-repository ppa:deadsnakes/ppa
apt update
apt install python3.8
Regarding your other two bullet points:
Yesn't. The thing is that, by default, /usr/bin is included in your PATH environment variable, which what enables you to just type python ... instead of providing the absolute path for the binary. It is also expected by some scripts, I suppose.
You could, and you could also symlink it. The reason why it wasn't put there already is because the article used altinstall, which prevents exactly that. It is way more preferable that you install stuff through your package manager, however.

Upgraded Python; Do I have to reinstall all site-packages manually?

I have upraded my Linux distro recently. Python 3.5 was replaced by Python 3.6.
All site packages I have installed with pip3 are still in the /usr/lib/python3.5/site-packages directory and Python does not find them there now, because it looks in .../python3.6/site-packages obviously.
I see the directory contents and I could manually install them again, but that does not look to me like the right way to do it. I could move the contents to the new directory, but again, this seems to me incorrect either.
How am I supposed to handle it properly?
Should I have prepared a pip3 freeze list before the upgrade?
I tried to search, but the keywords are probably too general and got many unrelated answers.
Python 3.5 was replaced by Python 3.6. But you still have the backup option of using python 3.5.
If you want to use python 3.6 you will have to reinstall all pip packages again for python 3.6. And it makes sense.
Say you were changing from 2.7 to 3.5. You would want to preserve both the environments separately. Hence 3.6 environment is different from 3.5.
A quick way to do this would be to pip freeze for 3.5 and then install those dependencies for 3.6.
pip freeze > reqs.txt
upgrade
pip install -r reqs.txt
Since you don't have this option anymore, first try and list all packages in your python3.5
for that you can install pip3.5 as answered by #kabanus.
sudo apt-get install python3=3.5.1*
sudo python3.5 easy_install.py pip
Also it's advised to use virtual environment per project so you can maintain separate environments for each of them.
I just hit the same problem upgrading from Python 3.6 to Python 3.7, I forgot to run pip freeze before I upgraded to Python 3.7. The solution that worked is to specify the --path option as the old site-packages/ directory (which was not deleted):
pip3 freeze --path /usr/local/lib/python3.6/site-packages/ > python3.6_requirements.txt
pip3 install -r python3.6_requirements.txt
This would have made things simpler for you to reinstall. Checkout the description. Using freeze you could have done something like:
$ env1/bin/pip3 freeze > requirements.txt
$ env2/bin/pip3 install -r requirements.txt
Generally the recommended method is you use a virtualenv for site packages, so you don't litter your installation areas, but TBH it never broke something for me. Another option is to check if the linux distribution has the package available for proper retrieval, as in:
sudo apt-get install python3-<somemodule>
This is what I prefer - and could have been upgraded with the distro. As for what to do now, If you really don't want to re-install everything properly you could try to cp /usr/lib/python3.5/site-packages/* /usr/lib/python3.6/site-packages. The differences between versions are not so great such that I believe most packages would work off the bat. You may have to sed to replace python3.5 with python3.6 in all files there though. Forgot delete all pyc files if you do this.
Python modules are self contained enough that if something is broken it can be handled per package, and the site packages are self contained completely, so you could always just remove everything and re-install.
A final note - you can try and install pyton3.5/pip3.5 for your linux, and then do the freeze thing. If there is no package you could install manually (whl or such) or compile a stand alone and configure the site path properly. If you want to keep things on a global site package directory or migrate to virtualenv this may be the safest option.

Reinstall python 2.7.12 and python 3.5.2

Good evening,
today i messed up my laptop trying to install some packages for python 3.5.2. I tried to install the correct pip version but i missed something and now i can't install any package in both versions and i can't solve the problem. Is it possible to unistall the 2 versions (including all packages) and reinstall everything? I don't use Python 2.7.12 (but i'l like to have a clean version of it), i need python 3.5.2 with the correct pip version to install, for example, the packages NumPy, SciPy, matplotlib etc.
Thanks in advance,
J
I'd highly recommend using virtualenv, and never modifying the system python, except to install pip and virtualenv if necessary.
As was alluded to above, many OSes count on having a working python2 in order to function.
So...
[UPDATE: this worked in 2017, and may not work well in later years!]
apt-get remove python3
apt-get install python3
pip3 install virtualenv
virtualenv -p python3 venv
. venv/bin/activate
# now you are in a nice python3 world, completely isolated from system python
# remember to say . venv/bin/python every time you do anything
# or you can even add it to your .bashrc

Is it dangerous if I uninstall all the packages in `pip list` on MacOS?

The python I use is the one of MacOS. It seems that the python of the system did not carry pip, and pip is installed by myself.
It's very annoying to use the python of the system, there is always the "Permission denied" issue and I'm tired of this. So, I want to uninstall all the packages by pip firstly, and then use virtualenv. Before that, I'd like to know
Is it dangerous if I uninstall all the packages in pip list on MacOS?
Edit: Currently, there are both Python 2.6 and 2.7 on my mac in the directory: /Library/Python. Then can I remove python 2.7 totally and reinstall it in another way?
Do not uninstall MacOS python packages. I did that once. Wasn't a fun time. Even installing new packages can lead to huge problems as dependencies get updated and no longer work with OSX stuff, particularly stuff you can't even update because of SIP.
If you make a virtualenv, it will be totally separate from the OSX python. You can use pip in the virtualenv and it will not effect the pip outside of the virtualenv. In otherwords, you don't need to remove anything - just make the virtualenv and start pip insall'ing :)
I ended up installing Anaconda Python from Continuum Analytics and then setting my path to that python. This way I got an updated python to work with (plus a bunch of other advantages) but my Mac could keep Python 2.6 it needs to operate properly.

Uninstall python built from source?

I've installed python 2.6 from source, and somehow later mistakenly installed another python 2.6 from a package manager too.
I can't find a way to uninstall a python that was built from source, is this possible/easy?
Running ubuntu 10.04.
You can use checkinstall to remove Python. The idea is:
Install checkinstall
Use
checkinstall to make a deb of your
Python installation
Use dpkg -r to
remove the deb.
See this post for more details.
PS. Note that Ubuntu must always have at least one installation of Python installed, or else major pieces of your OS stop working. Above, I'm assuming it's safe to remove the Python built from source, without removing the Python that was installed by the package manager.
PPS. If you accidentally erase all Python installations from your Ubuntu machine, all is not lost. Instructions on how to recover from this situation can be found here.
I did the following and reinstall using 'make install' and it worked.
whereis python3.6
rm -rf /usr/local/lib/python3.6
rm -rf /usr/local/bin/python3.6*
make install
Have you looked into
make uninstall
I believe this should work for you, assuming you have the python 2.6 source and the make file has uninstall available (it should).
http://www.linuxquestions.org/questions/linux-newbie-8/source-uninstall-with-make-uninstall-howto-230225/
In the future it may be prudent to use sudo checkinstall.
Below command removed all the things it installed for me.
make -n install
Do you still have the source directory where you compiled Python before? If so, you can CD into that directory and run sudo make uninstall.
If you don't have it still, you could re-create it by going through the build steps again--download, extract, configure, and make--but end with sudo make uninstall instead of sudo make install, of course.

Categories