English 中文(简体)
无法找到包裹
原标题:Unable to locate package python-pytest

I had to reset my machine recently, and so have to re-install everything again.

I want to run a Python file using PyTest.

Bash码头:

me@PF2DCSXD:/mnt/c/Users/dabell/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ pytest -s test_composite_key.py

Command  pytest  not found, but can be installed with:

sudo apt install python-pytest

me@PF2DCSXD:/mnt/c/Users/dabell/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ sudo apt install python-pytest
[sudo] password for danielbellhv: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-pytest

Solution之后,我得以安装pip

Please let me know if there is anything else I can add to post.

最佳回答

我必须首先安装pip,作为

sudo apt-get update
sudo apt-get upgrade  #Optional
sudo apt install python3-pip

Then

$ pip install pytest
Collecting pytest
  Downloading pytest-6.2.5-py3-none-any.whl (280 kB)
     |████████████████████████████████| 280 kB 621 kB/s 
Collecting packaging
  Downloading packaging-21.2-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 1.1 MB/s 
Collecting iniconfig
  Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting pluggy<2.0,>=0.12
  Downloading pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting py>=1.8.2
  Downloading py-1.10.0-py2.py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 1.1 MB/s
Collecting toml
  Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: attrs>=19.2.0 in /usr/lib/python3/dist-packages (from pytest) (19.3.0)
Collecting pyparsing<3,>=2.0.2
  Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 1.1 MB/s
Installing collected packages: pyparsing, packaging, iniconfig, pluggy, py, toml, pytest
  WARNING: The scripts py.test and pytest are installed in  /home/danielbellhv/.local/bin  which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed iniconfig-1.1.1 packaging-21.2 pluggy-1.0.0 py-1.10.0 pyparsing-2.4.7 pytest-6.2.5 toml-0.10.2

Note:

$ pip install python-pytest
ERROR: Could not find a version that satisfies the requirement python-pytest (from versions: none)
ERROR: No matching distribution found for python-pytest
问题回答

Installing pip worked for me!

Also to install pytest coverage use the command below:

pip install pytest-cov




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签