[英]'py.test' is not recognized as an internal or external command, operable program or batch file
[英]on MAC OS X, py.test not recognized as a command
在 MAC OS X 10.10 上; 我安裝了pytest 2.6.4; 但是在終端如果我寫 py.test 甚至 py.test --version; 我收到錯誤:
-bash: py.test command not found
(a) 我錯過了什么嗎? 我該怎么做才能使 pytest 工具可識別。 我搜索了很多; 但除了http://teckla.idyll.org/~t/transfer/py.test.html之外找不到任何信息
我檢查了 PyCharm 首選項,我沒有看到那里列出了 py.test 解釋器。 但是,pip freeze 顯示已安裝 pytest 2.6.4。
(b) 是否需要在 MAC 上設置 PYTHONPATH? 盡管我已經看到在 Windows 上不需要設置它。
感謝任何幫助我解決這個問題的指針。
更新:我的 bash_profile 的內容:
echo export PATH="HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"
PATH="/Users/admin/Library/Python/2.7/lib/python/site-packages:$PATH"
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH"
export PATH
在 OS X 上你應該這樣做:
pip install -U pytest
或者
easy_install -U pytest
對於我們這些試圖避免任何和所有使用sudo
:
$ cd <pytest download folder>
$python setup.py build
$python setup.py install --user
PATH
。$py.test --version
確認設置有效終於搞定了! 下載 pytest 后,我運行了以下命令,它就像魔術一樣工作。 我想,早些時候,我錯過了在安裝命令前面放置“sudo”:
$python setup.py build
$sudo python setup.py install
輸出說:
..
Installing py.test script to /usr/local/bin
Installing py.test-2.7 script to /usr/local/bin
Installed /Library/Python/2.7/site-packages/pytest-2.6.4-py2.7.egg
..
Using /Users/admin/Library/Python/2.7/lib/python/site-packages
Finished processing dependencies for pytest==2.6.4
我的 .bash_profile 內容,jfyr:
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/System/Library/Frameworks/Python.framework/Versions/2.7/bin"
export PATH
pip3 install -U pytest 使用 Python 3.7 版本
我在 Mac M1 上安裝 pytest 時遇到問題,但我遵循了 python pip 文檔並且它工作正常。 我所做的是:
通過 Pycharm 終端中的命令安裝 pip(我使用 pycharm):python3 -m pip install pytest
安裝后,我使用命令從終端運行 pytest:python3 -m pytest "name_of_the_file.py"
這有效。 在 Mac 上,我需要用“python3”作為所有命令的前綴,因為我猜 Mac 有自己的內置 Python,但那是 Python 2,所以為了在我的 Pycharm(即 Python 3)上運行代碼,我需要在命令中使用該前綴...不確定雖然我是新手,但我猜是這樣的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.