Issue
I just installed ipython
on root/global (i.e. just with apt install ipython ipython3
not inside a venv) on my Linux Mint 19.3 machine. However, trying to run it gives an error:
user@computer:/media/disk/dir$ ipython
/home/user/.local/bin/ipython: 2: exec: /media/disk/venv/bin/python3: not found
user@computer:/media/disk/dir$ ipython3
/home/user/.local/bin/ipython3: 2: exec: /media/disk/venv/bin/python3: not found
The error is that it is trying to load virtual environments automatically but they don't exist (anymore). I can't figure out why it does this.
Could not find a question about this, there are many about running from a virtual environment on purpose, but I want to just run it normally.
My python bins are in the usual place:
user@computer:/media/disk/dir$ which ipython
/home/user/.local/bin/ipython
user@computer:/media/disk/dir$ which ipython3
/home/user/.local/bin/ipython3
Running just python3
normally seems to work fine with regards to paths:
user@computer:/media/disk/dir$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/user/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages']
>>> import os
>>> os.getcwd()
'/media/disk/dir'
System:
user@computer:/media/disk/dir$ lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 19.3 Tricia
Release: 19.3
Codename: tricia
I don't have anything relevant set in ~/.bashrc
.
More information:
user@computer:/media/disk/dir$ type -a python3 ipython3
python3 is /usr/bin/python3
ipython3 is /home/user/.local/bin/ipython3
ipython3 is /usr/local/bin/ipython3
ipython3 is /usr/bin/ipython3
user@computer:/media/disk/dir$ head -1 -- $(type -P ipython3)
#!/bin/sh
These look normal to me.
Solution
APT installs IPython 3 at /usr/bin/ipython3
.
That means you have an extra IPython install at ~/.local/bin/ipython3
, which references the virtualenv. If you still had the virtualenv I would say use pip to uninstall it, but since the virtualenv is gone, I think you can remove it manually.
And you might have another extra at /usr/local/bin/ipython3
, but I'm not sure. That's where sudo pip
would install it.
Now that said, in my experience with using IPython and pip on Ubuntu (similar to Mint), the default repos are always sorely out of date. The best solution I've found personally is to set up a virtualenv in my home folder and install IPython in it, then link it into my PATH in ~/.local/bin
, just like the setup you had.
Answered By - wjandrea Answer Checked By - Marie Seifert (WPSolving Admin)