douti0467
2017-11-22 19:06
浏览 16
已采纳

直接调用与Python子流程时,GOPATH的解释不同

I recently found a fix for Python getpass not working on Windows: Python not working in the command line of git bash

Or at least that was the last thing I remember about changing my python configurations. (This is for Python 3.6.1 on Windows 10)

Now I also use Python to other tasks which simply has subprocess calls to type several commands on terminal:

go build ./folder/
mv ./src/ ./bin/

I get the error: go: GOPATH entry is relative; must be absolute: "/c/Users/OP/work". But I don't get it if I type go build ./src/folder myself. I have GOPATH set to C:\work in Environment Variables. I have tried with a ;.

Is there a way to reverse the alias python every time? Or what is happening exactly when setting an alias for python to winpty?

I'm thinking that when I call go build directly, it is called by either my user profile or system. And when python's subprocess calls it, it calls the opposite. Therefore, I have two GOPATH variables even though I have only 1 set in environment variable.

Side Note: another recent change on GOPATH was changing it from C:/go because it couldn't be the same as GOROOT. That error popped up randomly for some reason. It worked with that setting for a while and I don't remember changing anything before except adding another import package on top of the many other ones already being used.

Update: with type python I get the result: python is aliased to 'winpty python.exe'. Therefore I tried to undo that with unalias python. The new result I get is: python is hashed (/c/Users/OP/AppData/Local/Programs/Python/Python36/python).

This fixed the go build command within Python's subprocess. However, that alias was a fix for another Python issue with using getpass package.

图片转代码服务由CSDN问答提供 功能建议

我最近发现了针对Python getpass的修复程序,无法在Windows上使用: Python在git bash的命令行中不起作用 </ p> < p>或者至少那是我记得改变我的python配置的最后一件事。 (这适用于Windows 10上的Python 3.6.1)</ p>

现在,我还将Python用于其他任务,这些任务仅具有子进程调用即可在终端上键入多个命令:</ p> \ n

 开始构建./folder/
mv ./src/ ./bin/
 </ pre> 
 
 

我收到错误: go: GOPATH条目是相对的; 必须是绝对的:“ / c / Users / OP / work” </ code>。 但是如果我自己输入 go build ./src/folder </ code>,我不会理解。 我在环境变量中将GOPATH设置为 C:\ work </ code>。 我尝试使用; </ code>。</ p>

是否有一种方法可以每次都反转别名python? 还是将python的别名设置为winpty时到底发生了什么?</ p>

我在想,当我直接调用go build时,它是由用户配置文件或系统调用的。 当python的子进程调用它时,它调用相反的函数。 因此,即使我在环境变量中只设置了1个变量,我也有两个GOPATH变量。</ p>

侧面注意:GOPATH的另一项近期更改是将其从 C:/ go </ 代码>,因为它与GOROOT不能相同。 由于某种原因,该错误随机弹出。 它可以使用该设置一段时间,除了在已经使用的许多其他导入包之上添加另一个导入包之外,我不记得要进行任何更改。</ p>

更新:带有 输入python </ code>即可得到结果: python的别名为“ winpty python.exe” </ code>。 因此,我尝试使用 unalias python </ code>撤消该操作。 我得到的新结果是: python被散列了(/ c / Users / OP / AppData / Local / Programs / Python / Python36 / python)</ code>。 </ p>

这修复了Python子进程中的 go build </ code>命令。 但是,该别名是使用getpass软件包解决另一个Python问题的方法。</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题