Preface
I had a system-wide installation of Ipython which was working fine. However, when I was working in a virtual environment and had to install ipython there, running it from there gave the following error:
File "/usr/bin/ipython", line 26, in <module>
import IPython.Shell
ImportError: No module named Shell
Current problem
Unfortunately I accidently removed the ipython file in /usr/bin. So calling ipython from inside or outside the virtual environment now gives this error:
bash: /usr/bin/ipython: No such file or directory
The following ipython-related files are currently in /usr/bin:
/usr/bin$ find ipython*
ipython2.6
ipython2.7
ipython-wx
ipythonx
If I remove all these files, will a fresh system-wide ipython install reinstall these files?
(I have my doubts since I reinstalled it and it didn’t add the deleted ipython file. in /usr/bin)
What should I do to fix this?
Extra info
I am using python2.7
Edit
When I replace the first line of the new /usr/bin/ipython file to #!/usr/bin/python as Monir suggested I get this error:
Traceback (most recent call last):
File "/usr/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2676, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: ipython==0.13.1
— putting as answer to close this qn–
Try searching for the ipython executable inside the virtual env and copying it to /usr/bin. If the system-wide ipython version was same as the one installed in the virtual env, this should work.
As requested, I am pasting my /us/bin/ipython:
This is pointing to system python, so has access to necessary system-wide packages instead of the virtual env python. Run a “which python” on a directory outside your virtualenv and put that path in the first line after the sha-bang. (most probably it wil be /usr/bin/pyhton)
–Update: pasting part from recent comment to get this answer accepted and the qn closed.
If all else fails, try reinstalling ipython at system level. Not sure if you already tried that in the first place.