Moving Python installation folder does not update ipython paths

不打扰是莪最后的温柔 提交于 2020-01-26 02:19:09

问题


I moved my Python 2.7 installation from C:\Python to D:\Python by simply moving the folder (I understand there are other ways to do this). When running D:\Python\python.exe, I can import system libraries and run things without any issues. However, I cannot run D:\Python\Scripts\ipython.exe. I get the following error:

Fatal error in launcher: Unable to create process using '"C:\Python\python.exe" 
"D:\Python\Scripts\ipython.exe" '

It seems that ipython is aware of its original installation directory C:\Python, and attempts to access it. Are there any startup options or enviornmental variables I can use to force ipython to use the new installation directory?

Thanks.

EDIT:

The following process works completely fine. I first start Python via D:\Python\python.exe, and then run:

import IPython
IPython.start_ipython()

Why would this be different from running D:\Python\Scripts\ipython.exe?


回答1:


I had this exact problem with respect to pip and had to upgrade my python installation to 2.7.6 and reinstall pip.




回答2:


I also ran into this issue. The problem is that pip hardcodes the path to the Python interpreter for the executables in the Scripts folder (in this case IPython) at the time of the installation.

I don't think that is a way to control which Python interpreter pip should use for the executables. Currently, there are a couple of open issues on Github for pip that indicate that this is still an unsolved issue, e.g. https://github.com/pypa/pip/issues/2845.

However, I found a workaround described in this post http://www.clemens-sielaff.com/create-a-portable-python-with-pip-on-windows/ that works for me. Basically, just open the exe file in a text editor and edit the path to the Python interpreter (you will find it almost at the end of the file as #!<your path>). I'm using #!python since I know that my Python interpreter of choice will be first in path.



来源:https://stackoverflow.com/questions/23371712/moving-python-installation-folder-does-not-update-ipython-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!