无法在macOs上安装pytest高山脉

时间:2017-12-11 19:28:55

标签: pytest

所以现在安装完成了,它没有检测到它已安装,它告诉我找不到pytest命令 这是命令:

pytest --version

这是错误:

Mostafas-MacBook-Pro:bin mostafa.osama2$ pip install --user -U pytest
Collecting pytest
  Downloading pytest-3.3.1-py2.py3-none-any.whl (184kB)
    100% |████████████████████████████████| 194kB 4.0MB/s 
Requirement already up-to-date: pluggy<0.7,>=0.5 in /Library/Python/2.7/site-packages (from pytest)
Requirement already up-to-date: attrs>=17.2.0 in /Library/Python/2.7/site-packages (from pytest)
Requirement already up-to-date: py>=1.5.0 in /Library/Python/2.7/site-packages (from pytest)
Requirement already up-to-date: funcsigs; python_version < "3.0" in /Library/Python/2.7/site-packages (from pytest)
Collecting setuptools (from pytest)
  Downloading setuptools-38.2.4-py2.py3-none-any.whl (489kB)
    100% |████████████████████████████████| 491kB 2.4MB/s 
Collecting six>=1.10.0 (from pytest)
  Using cached six-1.11.0-py2.py3-none-any.whl
Installing collected packages: setuptools, six, pytest
Successfully installed pytest-3.3.1 setuptools-38.2.4 six-1.11.0
Mostafas-MacBook-Pro:bin mostafa.osama2$ pytest --version
-bash: pytest: command not found

1 个答案:

答案 0 :(得分:0)

您在输出顶部有解释:

  

目录&#39; /Users/mostafa.osama2/Library/Caches/pip/http'或其父目录不归当前用户所有,并且已禁用缓存。请检查该目录的权限和所有者。如果用sudo执行pip,你可能需要sudo&#39; -H标志。

     

目录&#39; /Users/mostafa.osama2/Library/Caches/pip'或其父目录不归当前用户所有,并且已禁用缓存轮。检查该目录的权限和所有者。如果用sudo执行pip,你可能需要sudo&#39; -H标志。

首先要做的是将这些目录更改回用户,可能使用:

chown -R mostafa.osama2 /Users/mostafa.osama2/Library/Caches/pip

然后,您需要决定如何在本地应用程序或主目录中安装模块。除非您希望模块在系统范围内可见,否则您可以执行以下操作:

pip install --user -U pytest