GVKun编程网logo

在bash中,“哪”给出了错误的路径-Python版本(bash报错)

25

关于在bash中,“哪”给出了错误的路径-Python版本和bash报错的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于anaconda的python版本与本地python版本不同时的问题

关于在bash中,“哪”给出了错误的路径-Python版本bash报错的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于anaconda的python版本与本地python版本不同时的问题、Bash中的表达式递归级别超出了错误、delphi – TOSVersion给出了错误的结果、java – Matmap的位图给出了错误的颜色等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

在bash中,“哪”给出了错误的路径-Python版本(bash报错)

在bash中,“哪”给出了错误的路径-Python版本(bash报错)

谁能解释默认情况下如何在我的计算机上运行python 2.6?似乎 python指向2.7,所以似乎which没有给我正确的信息。

~> python --versionPython 2.6.5~> which python/opt/local/bin/python~> /opt/local/bin/python --versionPython 2.7.2~> ls -l /opt/local/bin/pythonlrwxr-xr-x  1 root  admin  24 12 Oct 16:02 /opt/local/bin/python -> /opt/local/bin/python2.7

当我产生错误时,我看到了真正正在运行的东西。为什么会这样呢?

~> python -error-making-argumentUnknown option: -eusage:     /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python [option] ... [-c cmd | -m mod | file | -] [arg] ...Try `python -h'' for more information.

我该如何纠正呢?

- - 编辑: - -

从评论中的建议:

~> aliasalias cp=''cp -i''alias gcc=''gcc -Wall''~> type pythonpython is /opt/local/bin/python

答案1

小编典典

Bash使用内部哈希表来优化$PATH查找。当您python在您的较早位置安装了一个与现有程序同名的新程序时$PATH,Bash对此一无所知,并继续使用旧程序。该which可执行文件做了全面$PATH的搜索和打印出想要的结果。

要解决此问题,请运行命令hash -dpython。这python将从Bash的哈希表中删除,并$PATH在下次调用它时强制它进行完全搜索。或者,您也可以运行hash-r以完全清除哈希表。

type 内建将告诉你如何在给定命令将被解释。如果它说命令被散列,则意味着Bash将跳过$PATH对可执行文件的搜索。

anaconda的python版本与本地python版本不同时的问题

anaconda的python版本与本地python版本不同时的问题

在用anaconda,尤其是win下的时候,本地的python版本可能和虚拟环境中需要的python版本不同,而在虚拟环境中使用pip3安装包的时候,仍会出现版本是本地的python版本的情况,虽然并不是很清楚原因,不过记录并揣测一下。

 1 (base) C:\Users\Renyi>conda create --name yolov3 python=3.7
 2 Solving environment: done
 3 
 4 
 5 ==> WARNING: A newer version of conda exists. <==
 6   current version: 4.5.4
 7   latest version: 4.6.8
 8 
 9 Please update conda by running
10 
11     $ conda update -n base conda
12 
13 
14 
15 ## Package Plan ##
16 
17   environment location: C:\Users\Renyi\Anaconda3\envs\yolov3
18 
19   added / updated specs:
20     - python=3.7
21 
22 
23 The following packages will be downloaded:
24 
25     package                    |            build
26     ---------------------------|-----------------
27     openssl-1.1.1b             |       he774522_1         5.7 MB
28     setuptools-40.8.0          |           py37_0         663 KB
29     certifi-2019.3.9           |           py37_0         155 KB
30     wincertstore-0.2           |           py37_0          13 KB
31     wheel-0.33.1               |           py37_0          57 KB
32     python-3.7.2               |      h8c8aaf0_10        17.7 MB
33     ca-certificates-2019.1.23  |                0         158 KB
34     pip-19.0.3                 |           py37_0         1.8 MB
35     ------------------------------------------------------------
36                                            Total:        26.3 MB
37 
38 The following NEW packages will be INSTALLED:
39 
40     ca-certificates: 2019.1.23-0
41     certifi:         2019.3.9-py37_0
42     openssl:         1.1.1b-he774522_1
43     pip:             19.0.3-py37_0
44     python:          3.7.2-h8c8aaf0_10
45     setuptools:      40.8.0-py37_0
46     sqlite:          3.27.2-he774522_0
47     vc:              14.1-h0510ff6_4
48     vs2015_runtime:  14.15.26706-h3a45250_0
49     wheel:           0.33.1-py37_0
50     wincertstore:    0.2-py37_0
51 
52 Proceed ([y]/n)? y
53 
54 
55 Downloading and Extracting Packages
56 openssl-1.1.1b       |  5.7 MB | ############################################################################## | 100%
57 setuptools-40.8.0    |  663 KB | ############################################################################## | 100%
58 certifi-2019.3.9     |  155 KB | ############################################################################## | 100%
59 wincertstore-0.2     |   13 KB | ############################################################################## | 100%
60 wheel-0.33.1         |   57 KB | ############################################################################## | 100%
61 python-3.7.2         | 17.7 MB | ############################################################################## | 100%
62 ca-certificates-2019 |  158 KB | ############################################################################## | 100%
63 pip-19.0.3           |  1.8 MB | ############################################################################## | 100%
64 Preparing transaction: done
65 Verifying transaction: done
66 Executing transaction: done
67 #
68 # To activate this environment, use
69 #
70 #     $ conda activate yolov3
71 #
72 # To deactivate an active environment, use
73 #
74 #     $ conda deactivate

 

这里我新建了一个python3.7的虚拟环境,提示中安装的是基于3.7的pip

 

 1 (base) D:\PyCode\yolov3>conda activate yolov3
 2 
 3 (yolov3) D:\PyCode\yolov3>python
 4 Python 3.7.2 (default, Feb 21 2019, 17:35:59) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
 5 Type "help", "copyright", "credits" or "license" for more information.
 6 >>> exit(0)
 7 
 8 (yolov3) D:\PyCode\yolov3>pip3 install -U -r requirements.txt
 9 Collecting numpy (from -r requirements.txt (line 3))
10   Downloading https://files.pythonhosted.org/packages/ed/29/d97b6252591da5f8add0d25eecda296ea72729a0aad7998edba1981b47c8/numpy-1.16.2-cp36-cp36m-win_amd64.whl (11.9MB)
11     0% |                                | 61kB 28kB/s eta 0:07:00
12 Operation cancelled by user

 

接着我进入了刚创建完的虚拟环境,python是3.7.2版本的,然后我运行pip3来安装requirements.txt,里面有numpy,发现安装的版本是python3.6的

于是我终止了安装,并猜测,可能此时pip是更新过的,但pip3不是(未经验证) --  试了一下用pip指令就是cp37的内容了,那应该就是将pip更新成了python3.7的,但pip3没有,用get-pip.py能将pip3也更新成python3.7版本的

不过总之尝试了若干次,我发现此时更新一下pip就好了,我的更新方法还是有get-pip.py

文件地址:

https://bootstrap.pypa.io/get-pip.py

参见:

https://www.cnblogs.com/cenariusxz/p/8611796.html

 

 1 (yolov3) D:\PyCode\yolov3>python get-pip.py
 2 Collecting pip
 3   Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl
 4 Installing collected packages: pip
 5   Found existing installation: pip 19.0.3
 6     Uninstalling pip-19.0.3:
 7       Successfully uninstalled pip-19.0.3
 8 Successfully installed pip-19.0.3
 9 
10 (yolov3) D:\PyCode\yolov3>pip3 install -U -r requirements.txt
11 Collecting numpy (from -r requirements.txt (line 3))
12   Downloading https://files.pythonhosted.org/packages/3a/3c/515afabfe4f29bfc0a67037efaf518c33d0076b32d22ba865241cee295c4/numpy-1.16.2-cp37-cp37m-win_amd64.whl (11.9MB)
13     8% |██▌                             | 962kB 6.6kB/s eta 0:27:35

 

虽然看起来就是把pip-19.0.3删了再装了一次,不过这个时候再装环境,就是python3.7下的numpy了

Bash中的表达式递归级别超出了错误

Bash中的表达式递归级别超出了错误

我是打击脚本并试图做一些练习的新手.当我试图用“完成”字符串停止程序时,得到这样的错误:

line 9: ((: finish: expression recursion level exceeded (error token is "finish").

问题是什么?我还想了解其他的错误.
我的计划是:

#!/bin/bash
number=0
finish="finish"
temp=0
echo "Enter a number."
while true;
do
    read -r number
    if (( $number > $temp ))
    then
        temp=$number
    fi
    if [[ $number == $finish ]]
    then 
       break
    fi
done    
echo "Largest : $temp"

解决方法

从 @barmar’s great answer引用相关问题,该问题讨论了@GordonDavisson在评论中提到的同一问题:

When you use a variable in an arithmetic expression,but the value is
not a number,the shell treats it as another expression to evaluate.
So if the value is a variable name,it will get the value of that
variable and use it. But in this case,you have it pointing to itself.
So to evaluate a it has to evaluate $finish,and this keeps
repeating infinitely.

最简单的解决方案是为变量使用不同的名称 – 比如finish_string =“finish”而不是finish =“finish”.

此外,您可以使用正则表达式匹配来查看值是否为数字(注意:在算术表达式((…)中)扩展变量不需要美元符号),然后执行数字比较,然后进行正常的字符串比较查看值是否为“完成”:

if [[ $number =~ ^[0-9]+$]] && ((number > temp)); then
  temp=$number
elif [[ $number == $finish ]]; then
  break
fi

或者,您可以在进行数字比较之前明确检查用户是否输入了数字:

if [[ $number == $finish ]]; then
  break
else
  [[ $number =~ ^[0-9]+$]] || { echo "Enter a valid number or 'finish' to stop"; continue; }
  if ((number > temp)); then
    temp=$number
  fi
fi

使用bash -x yourscript.sh运行脚本进行调试.

有关:

> Expression recursion level exceeded

也可以看看:

> How to use double or single brackets,parentheses,curly braces

delphi – TOSVersion给出了错误的结果

delphi – TOSVersion给出了错误的结果

我的计算机上安装了客户端64位 Windows 7.下面相同的代码在虚拟应用程序和我的应用程序中给出了不同的结果我的应用程序是组项目,有25个包.

TOsversion.Name: Windows 7
TOsversion.ToString: Windows 7 Service Pack 1 (Version 6.1,Build 7601,64-bit Edition)

TOsversion.Name: Windows XP
TOsversion.ToString: Windows XP Service Pack 3 (Version 5.1,Build 2600,64-bit Edition)

可能导致什么问题?

清单文件设置自动生成.没有.manifest文件,但我可以在两个项目的.res文件中找到“supportedOS”条目.它们都具有相同的内容,如下所示:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
        <!--The ID below indicates app support for Windows Vista -->
        <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
        <!--The ID below indicates app support for Windows 7 -->
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
        <!--The ID below indicates app support for Windows 8 -->
        <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
        <!--The ID below indicates app support for Windows 8.1 -->
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
        <!--The ID below indicates app support for Windows 10 -->
        <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>          
    </application> 
</compatibility>

解决方法

可能的原因是兼容性修复 (a shim)应用于客户端计算机上的可执行文件;特别是 WinXPSP3VersionLie修复.
TOsversion记录使用GetVersionEx来确定其类构造函数中的OS版本,该版本由垫片作为 documented实现.

验证的一种方法是检查事件日志.将记录一个事件,即通过程序属性对话框(support article)或Program Compatibility Assistant或Application Compatibility Toolkit应用修复程序的用户.您可以搜索可执行文件的名称.

Event Log\Application and Services\Microsoft\Windows\Application-Experience\Program-Telemetry

java – Matmap的位图给出了错误的颜色

java – Matmap的位图给出了错误的颜色

所以我使用下一个代码从blob创建一个位图:

byte[] blob = contact.getMP();
ByteArrayInputStream inputStream = new ByteArrayInputStream(blob);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
Bitmap scalen = Bitmap.createScaledBitmap(bitmap, 320, 240, false);

并且它返回下一个输出,这很好

然后我执行以下操作将位图制作成Mat,但随后我的颜色才会改变……

//Mat ImageMat = new Mat();
Mat ImageMat = new Mat(320, 240, CvType.CV_32F);
Utils.bitmapToMat(scalen, ImageMat);

我不知道为什么,也不知道将位图变成Mat的另一种方法.怎么了?

解决方法:

Android Bitmap中的颜色通道格式为RGB
但是在opencv Mat中,默认情况下通道是BGR.

因此,当您执行Utils.bitmapToMat()时,[B,G,R]值存储在[R,G,B]通道中.红色和蓝色通道互换.

一种可能的解决方案是在opencv Mat上应用cvtcolor,如下所示:
Imgproc.cvtColor(ImageMat,ImageMat,Imgproc.COLOR_BGR2RGB);

它对我有用.

关于在bash中,“哪”给出了错误的路径-Python版本bash报错的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于anaconda的python版本与本地python版本不同时的问题、Bash中的表达式递归级别超出了错误、delphi – TOSVersion给出了错误的结果、java – Matmap的位图给出了错误的颜色等相关知识的信息别忘了在本站进行查找喔。

本文标签: