bash:“找不到命令",适用于python,r和nano [英] bash: 'command not found' for python, r and nano

查看:111
本文介绍了bash:“找不到命令",适用于python,r和nano的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git bash上,我收到针对pythonrnanocommand not found消息.

On git bash, I receive a command not found message for python, r and nano.

我在Windows 10上.我不知道自己在做错什么.

I am on Windows 10. I do not know what I am doing wrong.

我输入

r --version
python --version
nano --version

他们都返回command not found.

我读了一些我尝试过的东西

I read something that had me try

alias python='winpty python.exe'

,并将其重命名为python,但是当我尝试

and it renamed python, but when I tried

touch .bashrc

它返回了

触摸:找不到命令

touch: command not found

我按照Github课程PS239T中的说明进行操作.除了使这三个程序正常工作外,我还很幸运.

I followed the instructions in a Github course, PS239T. I have been fortunate, except for getting these three programs to work.

我尝试过

build/console.exe c:/Python36/python.exe

它返回了

build/console.exe:没有这样的文件或目录

build/console.exe: No such file or directory

我尝试过

PATH=$PATH:/c/Python36/

$ export PATH="$PATH:/c/Python36"

echo 'export PATH="$PATH:/c/Python36"' > .profile

一无所有.

我通过Anaconda获得了64位Python.

I got Python 64-bit via Anaconda.

我尝试设置Python 3.4环境

I tried setting up the Python 3.4 environment

conda create –n py34 python=3.4 anaconda

./python name_of_your_python_script.py

一无所有.

which python

给我一​​个巨大的目录路径:

got me a huge directory path:

which: no python in (/c/Users/Edward/bin:/mingw64/bin:/usr/local/bin:usr
/bin:/bin:/mingw64/bin:/usr/bin:c/user/Edward/bin:/c/Program Files
(X86)/Intel/ 1CLS client:/c/Program Files/Intel/1CLS Client:/c/Windows
/System32:/C/Windows:/C/Windows/Sytem32/Wbem:/c/Windows/System32
WindowsPowerShell/V1.0:/c/Program Files/Intel/Intel(R) Management Engine
Components/Dal:/c/Program Files/Intel/Intel(R) Management Engine
Components/IPT:/c/Program Files (x86)/Intel/Intel(R) magament Engine
Components/IPT:/c/Program Files (X86)/Intel/Intel(R) Management Engine
Components/IPT:/c/WINDOWS/Syste,32/Wbem:/c/WINDOWS/System32
/WindowsPowerShell/v1.0:/c/Program Files (x86)/Rand McNally/RNDDock
/GtkSharp/2.12/bin/:/c/Program Files d/AppData/Local/Mircosoft
/WindowsApps:/c/Users/Edward/AppData/Local/Pandoc:/usr/bin/vendor_perl:
/usr/bincore_perl:/c/python36  

我只是将截图或复制并粘贴,但我不知道如何.

I would have just put up the screenshot or copied and pasted it, but I do not know how.

我确定我在某处出错.

I am sure I made an error somewhere.

当我尝试弄清rnano的情况时,我得到的结果类型相同.

I get the same type of results when I try to figure out what is going on with r and nano.

下载并安装"Anaconda"

Download and install 'Anaconda'

'https://store.continuum.io/cshop/anaconda/'.  

下载默认的Python 3安装程序不遵循版本2的链接". 使用所有默认设置进行安装,但请确保选中将Anaconda设置为默认Python".

Download the default Python 3 installer 'do not follow the link to version 2'. Use all of the defaults for installation except make sure to check 'Make Anaconda the default Python.'

通过下载并运行

'this .exe file from CRAN'  

'http://cran.r-project.org/bin/windows/base/release.htm'.  

另外,请安装"RStudio IDE"

Also, please install the 'RStudio IDE'

'http://www.rstudio.com/ide/download/desktop'.  

您需要的只是RStudio Desktop.

All you need is RStudio Desktop.

nano是基本的编辑器,也是我们在此类中使用的默认编辑器.安装 下载Software Carpentry Windows installer

nano is a basic editor and the default that we use in this class. To install it, download the Software Carpentry Windows installer

http://files.software-carpentry.org/SWCarpentryInstaller.exe'  

,然后双击该文件以运行它. 此安装程序需要有效的Internet连接."

and double click on the file to run it. 'This installer requires an active internet connection.'

Sublime Text是更高级的编辑器.下载Sublime Text 3'here'

Sublime Text is a more advanced editor. Download Sublime Text 3 'here'

'https://www.sublimetext.com/3'.  

更新2

我开始尝试janos建议并运行

Update 2

I began trying janos advice and ran

/c/Python36/python.exe --version  

它返回

bash:'/c/python36/python.exe:没有这样的文件或目录.

bash: '/c/python36/python.exe: No such file or directory.

我尝试运行

PATH="/c/Python36:$PATH" python.exe --version  

但它返回了

bash:python.exe .:找不到命令

bash: python.exe.: command not found

我尝试运行

PATH="/c/Python36:$PATH" python --version  

它返回

bash:python:找不到命令

bash: python: command not found

更新3

janos告诉我我走得太远,没有弄清楚问题,然后告诉我跑步

Update 3

janos told me I went too far without figuring out the problem, then told me to run

ls -l /c/Python36/python.exe  

它返回

ls:无法访问"/c/Python36/python.exe":没有此类文件或目录.

ls: cannot access '/c/Python36/python.exe': no such file or directory.

janos告诉我要专注于第一个错误

janos told me to focus on the first error

bash:'/c/python36/python.exe:没有这样的文件或目录.

bash: '/c/python36/python.exe: No such file or directory.

输入后

/c/Python36/python.exe --version  

,因此我将重点关注.

and so there I will focus.

janos断言

您可以打开文件资源管理器并导航到C:\ Python36,然后在其中查看python.exe吗?可能不是.

Can you open a file explorer and navigate to C:\Python36, and see python.exe there? Probably not.

是正确的.

我跑了

C/Users/Edward/Anaconda3/pkgs/python-3.6.3-h9e2ca53_1/python.exe  

没有成功.

我在资源管理器中运行了它,发现发布者无法验证.

I ran that in explorer and found that the publisher could not be verified.

我去

'python.org/downloads/release/python-363'  

并下载"Windows x86可嵌入的zip文件",并将其解压缩为

and downloaded 'Windows x86 embeddable zip file' and Unzipped it in

C/Users/Edward/Anaconda3/pkgs

有效.

谢谢.

我敢打赌,"r"和"nano"也存在相同的问题.

I bet I am having the same problems with 'r' and 'nano'.

我将再次列出该列表并执行所有检查.我将对'r'和'nano'做同样的事情.

I am going to run down the list again and perform all the check. I will do the same thing with 'r' and 'nano'.

一切都适用于Python.我会在适当的时候做'nano'和'r'.

Everything worked out for Python. I will do 'nano' and 'r' in due course.

我找不到

/c/python36/  

所以我用了

/c/Users/Edward/Anaconda3/pkgs/python-3.6.3-embed-win32/  

更新5

janos再次正确.我将需要创建python36文件夹,因为它不是在安装过程中自动生成的. janos"方法适用于"r"和"subl"或崇高文本3.我放弃了"nano".

Update 5

janos is right again. I would need to create the python36 folder as it was not built automatically during the installation. janos' method worked on 'r' and 'subl' or sublime text 3. I gave up on 'nano'.

我发现我的某些'.exe'文件正在列表中,名称中带有空格.我移至用户文件夹并消除了所有空格.

I found that some of my '.exe' files were in listing with spaces in the names. I moved to the user folder and eliminated any spaces.

我还从官方网站下载了版本,这也有所帮助.

I also downloaded version from the official website, and that too helped.

我不知道如何使纳米"工作.我什至无法在我的电脑上找到它.我改用"subl".

I could not figure out how to get 'nano' to work. I could not even find it on my pc. I used 'subl' instead.

推荐答案

从基础开始.尝试最简单的可行方法, 并在婴儿脚步方面取得进步, 从一个理智的状态到另一个理智的状态.

Start from the basics. Try the simplest thing that can possibly work, and make progress in baby steps, from one sane state to the next.

第一步是通过直接输入其绝对路径来运行a. 如果Python可执行文件位于/c/Python36/python.exe,请运行以下命令:

The first step is to run a by entering its absolute path directly. If the Python executable is at /c/Python36/python.exe, then run this:

/c/Python36/python.exe --version

这非常简单,应该可以正常工作. 如果没有,该命令将为您提供一条错误消息和提示.

This is very simple and it should just work. If it doesn't, the command will give you an error message with clues.

下一步可能是模拟,将其添加到PATH.试试这个:

A next step could be to simulate adding to PATH. Try this:

PATH="/c/Python36:$PATH" python.exe --version

这是一行.它将值设置为PATH,以使其仅在命令执行期间处于活动状态.命令完成后,PATH的值将恢复为之前的值.这是测试事物的好方法.还要注意,我在之前添加了到包含python.exe的目录,而不是python.exe的完整路径. 这很重要,这就是PATH变量的工作方式. 这是目录的列表,这些目录中的所有可执行文件都可以通过简单地键入其名称而变得容易执行,而不必键入其绝对路径.

This is one line. It sets a value to PATH in a way such that it's only active during the execution of the command. After the command completes, the value of PATH will be back to what it was before. This is a good way to test things. Also notice that I prepended to PATH the directory that contains python.exe, not the full path to python.exe. That's an important point, this is how the PATH variable works. It's a list of directories, and all executable files in those directories become easily executable by simply typing their name, without having to type their absolute paths.

接下来,我将尝试以下操作:

Next, I would try this:

PATH="/c/Python36:$PATH" python --version

也就是说,看看是否可以从命令名称中删除.exe. 我没有Windows,所以我无法测试它是否有效. 也许不是. (但我认为是.)

That is, see if you can drop the .exe from the name of the command. I don't have Windows so I cannot test if this works. And maybe it doesn't. (But I think it does.)

如果到目前为止一切正常,那么下一步就是将PATH设置设为永久设置. 这样做的方法是将命令PATH="/c/Python36:$PATH"放入一个文件,该文件在启动新的Git Bash会话时始终执行. 如果我在Windows上没有记错,可以将其放在~/.profile (您的主目录中名为.profile的文件). ~在哪里?这是找到它的一种方法:

If everything worked so far, then the next step is to make the PATH setting permanent. The way to do that is to put the command PATH="/c/Python36:$PATH" into a file that is always executed when you start a new Git Bash session. If I remember correctly on Windows you can put it in ~/.profile (a file named .profile in your home directory). Where is ~? Here's one way to find it:

cd
explorer .

以上内容在该目录中打开一个文件管理器. 您可以使用记事本或写字板之类的纯文本编辑器进行编辑. 您也可以使用此shell命令附加更新PATH:

The above opens a file manager inside that directory. You can use a plain-text editor like Notepad or Wordpad to edit it. You can also use this shell command to append the line that updates PATH:

echo 'PATH="/c/Python36:$PATH"' >> ~/.profile

此行将在所有新的Git Bash会话中执行. 不在当前会话中, 因为此文件仅执行一次.

This line will get executed in all new Git Bash session. Not in the current session, because this file is only executed once.

如果以上所有操作均有效,则在新的Git Bash会话中,您应该能够运行python --version. 如果不是所有方法都奏效,那么您需要仔细阅读错误消息,直到问题解决后再进行下一步. 如果您尚未处于理智状态,则前进到下一步是没有用的.

If everything above worked, then in a new Git Bash session you should be able to run python --version. If not everything worked, then you need to read the error message you get carefully, and not advance to the next step until the problem is resolved. It's useless to advance to a next step when you are already not in a sane state.

对于其他所有程序,您也可以遵循完全相同的逻辑过程.

You can follow the exact same logical process for all the other programs too.

这篇关于bash:“找不到命令",适用于python,r和nano的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆