移动Python安装文件夹不会更新ipython路径

移动Python安装文件夹不会更新ipython路径

本文介绍了移动Python安装文件夹不会更新ipython路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过简单地移动文件夹将我的Python 2.7安装从C:\ Python移动到D:\ Piy(我知道还有其他方法可以做到这一点)。运行 D:\Python \ python.exe 时,我可以导入系统库并运行而不会出现任何问题。但是,我无法运行 D:\Python \Scripts\ipython.exe。我收到以下错误:

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" '

似乎ipython知道它的原始安装目录C:\ Pyy,并试图访问它。我可以使用任何启动选项或环境变量来强制ipython使用新的安装目录吗?

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?

谢谢。

编辑:

以下过程完全正常。我首先通过D:\Python \ python.exe启动Python,然后运行:

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

import IPython
IPython.start_ipython()

为什么这与运行D:\Python \Scripts \\不同\\ ipython.exe?

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

推荐答案

我也遇到过这个问题。问题是pip在安装时硬编码了Scripts文件夹(在本例中为IPython)中可执行文件的Python解释器的路径。

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.

我认为这不是控制哪个Python解释器pip应该用于可执行文件的方法。目前,Github上存在一些未解决的问题,表明这仍然是一个未解决的问题,例如: 。

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.

但是,我发现了这篇文章中描述的解决方法对我有用。基本上,只需在文本编辑器中打开exe文件并编辑Python解释器的路径(你会发现它几乎在文件末尾#!< your path> )。我正在使用#!python ,因为我知道我选择的Python解释器将首先出现在路径中。

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.

这篇关于移动Python安装文件夹不会更新ipython路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 00:13