Anaconda提示加载错误:输入行太长

时间:2016-01-15 19:21:36

标签: python batch-file windows-7-x64 anaconda prompt

我在Windows 7 64位版本上安装了Anaconda 64 python 2.7。 安装后,anaconda提示符可以启动没有问题。但每当我重新启动/关闭并重新启动笔记本电脑时,anaconda提示符将显示以下错误消息,并且一些python软件包在jupyter笔记本中加载时会出现问题。

Deactivating environment "C:\Users\user\Anaconda2"...
Activating environment "C:\Users\user\Anaconda2"...
The input line is too long.
 "PATH_NO_SCRIPTS=C:\Users\user\Anaconda2;;C:\Users\user\Anaconda2\Lib
rary\bin;C:\Python27\;C:\Python27\Scripts;c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;
C:\ProgramData\Oracle\Java\javapath;%COSMOSM%;C:\Program Files\Lenovo Fingerprin
t Reader\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS
Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP
\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program File
s (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R) Man
agement Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine
Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Component
s\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\
Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon
\;C:\Program Files\Sony\VAIO Improvement\;C:\Program Files (x86)\Sony\VAIO Start
up Setting Tool;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;
c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files
 (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxi
o 2010\OEM\AudioCore\;C:\Program Files (x86)\Common Files\Thunder Network\KanKan
\Codecs;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\IVI Foundat
ion\VISA\Win64\Bin\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Pro
gram Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files (x86)\IVI Founda
tion\IVI\bin;C:\Program Files\IVI Foundation\IVI\bin;C:\PROGRA~2\IVIFOU~1\VISA\W
inNT\Bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Users\user\AppData\Local\Smartbar\Application\;C:\Program Files (x86)\WinSCP\;C:\Python
27\Scripts;C:\Program Files\ffmpeg\bin;C:\Program Files\Microsoft SQL Server\110
\Tools\Binn\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files (x86
)\Windows Kits\8.1\Windows Performance Toolkit\;C:\HashiCorp\Vagrant\bin;C:\Prog
ram Files (x86)\Skype\Phone\;;C:\Users\user\Desktop\win64\\lib;C:\Users\user\Desktop\win64\\3rdparty\cudnn\bin;C:\Users\user\Desktop\win64\\3rdpa
rty\cudart;C:\Users\user\Desktop\win64\\3rdparty\vc;C:\Users\user\Desk
top\win64\\3rdparty\openblas\bin;C:\Python27\;C:\Python27\Scripts;c:\Rtools\bin;
c:\Rtools\gcc-4.6.3\bin;C:\ProgramData\Oracle\Java\javapath;%COSMOSM%;C:\Program
 Files\Lenovo Fingerprint Reader\;C:\Program Files (x86)\Intel\iCLS Client\;C:\P
rogram Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Pro
gram Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\Syste
m32\Wbem;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program
Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Int
el(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Man
agement Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management E
ngine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Fi
les\Intel\WirelessCommon\;C:\Program Files\Sony\VAIO Improvement\;C:\Program Fil
es (x86)\Sony\VAIO Startup Setting Tool" was unexpected at this time.

我尝试按照解决方案herehere进行操作,但没有成功。

我查看了Anaconda下的Script文件夹,发现错误消息可能来自activate.bat文件。但我不知道下一步该做什么。

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
REM Check for CONDA_ENVS_PATH environment variable
REM It it doesn't exist, look inside the Anaconda install tree
IF "%CONDA_ENVS_PATH%" == "" (
    REM turn relative path into absolute path
    CALL :NORMALIZEPATH CONDA_ENVS_PATH "%~dp0..\envs"
)

REM Used for deactivate, to make sure we restore original state after deactivation
IF "%CONDA_PATH_BACKUP%" == "" (SET "CONDA_PATH_BACKUP=%PATH%")

set "CONDA_NEW_NAME=%~1"

IF "%~2" == "" GOTO skiptoomanyargs
    ECHO ERROR: Too many arguments provided
    GOTO usage
:skiptoomanyargs

IF "%CONDA_NEW_NAME%" == "" set "CONDA_NEW_NAME=%~dp0.."

REM Search through paths in CONDA_ENVS_PATH
REM First match will be the one used

FOR %%F IN ("%CONDA_ENVS_PATH:;=" "%") DO (
    IF EXIST "%%~F\%CONDA_NEW_NAME%\conda-meta" (
       SET "CONDA_NEW_PATH=%%~F\%CONDA_NEW_NAME%"
       GOTO found_env
    )
)

IF EXIST "%CONDA_NEW_NAME%\conda-meta" (
    SET "CONDA_NEW_PATH=%CONDA_NEW_NAME%"
    ) ELSE (
    ECHO No environment named "%CONDA_NEW_NAME%" exists in %CONDA_ENVS_PATH%, or is not a valid conda installation directory.
    EXIT /b 1
)

:found_env

SET "SCRIPT_PATH=%~dp0"
IF "%SCRIPT_PATH:~-1%"=="\" SET "SCRIPT_PATH=%SCRIPT_PATH:~0,-1%"

REM Set CONDA_NEW_NAME to the last folder name in its path
FOR /F "tokens=* delims=\" %%i IN ("%CONDA_NEW_PATH%") DO SET "CONDA_NEW_NAME=%%~ni"

REM special case for root env:
REM   Checks for Library\bin on PATH.  If exists, we have root env on PATH.
call :NORMALIZEPATH ROOT_PATH "%~dp0.."
CALL SET "PATH_NO_ROOT=%%PATH:%ROOT_PATH%;=%%"
IF NOT "%PATH_NO_ROOT%"=="%PATH%" SET "CONDA_DEFAULT_ENV=%ROOT_PATH%"

REM Deactivate a previous activation if it is live
IF "%CONDA_DEFAULT_ENV%" == "" GOTO skipdeactivate
    REM This search/replace removes the previous env from the path
    ECHO Deactivating environment "%CONDA_DEFAULT_ENV%"...

    REM Run any deactivate scripts
    IF NOT EXIST "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d" GOTO nodeactivate
        PUSHD "%CONDA_DEFAULT_ENV%\etc\conda\deactivate.d"
        FOR %%g IN (*.bat) DO CALL "%%g"
        POPD
    :nodeactivate

    REM Remove env name from PROMPT
    FOR /F "tokens=* delims=\" %%i IN ("%CONDA_DEFAULT_ENV%") DO SET "CONDA_OLD_ENV_NAME=%%~ni"
    call set PROMPT=%%PROMPT:[%CONDA_OLD_ENV_NAME%] =%%

    SET "CONDACTIVATE_PATH=%CONDA_DEFAULT_ENV%;%CONDA_DEFAULT_ENV%\Scripts;%CONDA_DEFAULT_ENV%\Library\bin"
    CALL SET "PATH=%%PATH:%CONDACTIVATE_PATH%=%%"
    SET CONDA_DEFAULT_ENV=
:skipdeactivate

CALL :NORMALIZEPATH CONDA_DEFAULT_ENV "%CONDA_NEW_PATH%"

ECHO Activating environment "%CONDA_DEFAULT_ENV%"...
SET "PATH=%CONDA_DEFAULT_ENV%;%CONDA_DEFAULT_ENV%\Scripts;%CONDA_DEFAULT_ENV%\Library\bin;%PATH%"
IF "%CONDA_NEW_NAME%"=="" (
   REM Clear CONDA_DEFAULT_ENV so that this is truly a "root" environment, not an environment pointed at root
   SET CONDA_DEFAULT_ENV=
   ) ELSE (
   SET "PROMPT=[%CONDA_NEW_NAME%] %PROMPT%"
)

REM Make sure that root's Scripts dir is on PATH, for sake of keeping activate/deactivate available.
CALL SET "PATH_NO_SCRIPTS=%%PATH:%SCRIPT_PATH%=%%"
IF "%PATH_NO_SCRIPTS%"=="%PATH%" SET "PATH=%PATH%;%SCRIPT_PATH%"

REM Run any activate scripts
IF NOT EXIST "%CONDA_DEFAULT_ENV%\etc\conda\activate.d" GOTO noactivate
    PUSHD "%CONDA_DEFAULT_ENV%\etc\conda\activate.d"
    FOR %%g IN (*.bat) DO CALL "%%g"
    POPD
:noactivate

REM Trim trailing semicolon, if any
IF "%PATH:~-1%"==";" SET "PATH=%PATH:~0,-1%"

REM Clean up any double colons we may have ended up with
SET "PATH=%PATH:;;=;%"

ENDLOCAL & (
    SET "PATH=%PATH%"
    SET "PROMPT=%PROMPT%"
    SET "CONDA_DEFAULT_ENV=%CONDA_DEFAULT_ENV%"
    SET "CONDA_PATH_BACKUP=%CONDA_PATH_BACKUP%"
)

EXIT /B

:NORMALIZEPATH
    SET "%1=%~dpfn2"
    EXIT /B

任何提示都表示赞赏。

3 个答案:

答案 0 :(得分:12)

我发现如果你改变使用CALL SET的单引号:

REM Make sure that root's Scripts dir is on PATH, for sake of keeping activate/deactivate available.
CALL SET "PATH_NO_SCRIPTS=%%PATH:%SCRIPT_PATH%=%%"
IF "%PATH_NO_SCRIPTS%"=="%PATH%" SET "PATH=%PATH%;%SCRIPT_PATH%"

为:

REM Make sure that root's Scripts dir is on PATH, for sake of keeping 
activate/deactivate available.
CALL SET ""PATH_NO_SCRIPTS=%%PATH:%SCRIPT_PATH%=%%""
IF "%PATH_NO_SCRIPTS%"=="%PATH%" SET "PATH=%PATH%;%SCRIPT_PATH%"

为我解决这个问题。这是基于此answer

答案 1 :(得分:2)

同样的错误对我有用。

创建另一个系统变量 P1 变量值是您的Anaconda安装位置(我的位置):

C:\ Program Files(x86)\ Anaconda3 \

PATH 变量中,将这两个放在前面:

%P1%\envs;%P1%\Scripts\;everything_else_here 

重新启动命令提示符并尝试再次激活env。

答案 2 :(得分:1)

我遇到了同样的问题,它也发生在使用conda创建的激活环境中。 因为我在一个混乱的Windows PATH中遇到问题很长时间,我的解决方案是创建一个小的python工具来整理PATH变量。它可以通过

获得
>pip install pywinpath

接着是

>pywinpath

或者你可以复制&粘贴单个文件https://github.com/czamb/pywinpath/blob/master/pywinpath.py

中的源代码

或从https://github.com/czamb/pywinpath/releases

下载捆绑的.exe

然后,在PATH适合Windows长度限制之后,您可以在用户或系统路径的开头添加Anaconda的条目。 通过调用Anaconda Promt并输入echo%PATH%可以找到相关条目,它们是前三个条目。

还有其他工具可以编辑Windows PATH变量:https://superuser.com/questions/297947/is-there-a-convenient-way-to-edit-path-in-windows-7