Closed kochkinaelena closed 5 years ago
Hi @kochkinaelena, how are you running the tests? If I run any of the following commands I get sensible output:
From inside the top-level directory:
pytest
pytest tests
python -m pytest
python -m pytest tests
From inside the tests
directory
pytest
pytest .
plus associated other options eg. -v
.
Is the pytest
executable you are using aware of the current enviroment? If you installed pip install -r requirements.txt
then you won't get pytest
installed into your virtualenv by default as this is in requirements-dev.txt
. I can add pytest
to requirements.txt
if this is your problem.
Hi,
I get -bash: pytest: command not found
when trying pytest
or the error from my previous message if I do command with python -m pytest
Hi @kochkinaelena - are you running inside a virtual environment (eg. using virtualenv or pyenv or conda)? Can you list the packages you have installed (eg. with conda list
or pip list
) as well as
which python
python --version
which pip
pip --version
Hi, thank you for your response,
I did not create any special virtual environment for this You can see the results of commands you requested below:
Elenas-MacBook:~ Helen$ which python //anaconda/bin/python
Elenas-MacBook:~ Helen$ python --version Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
Elenas-MacBook:~ Helen$ which pip //anaconda/bin/pip
Elenas-MacBook:~ Helen$ pip --version pip 9.0.1 from //anaconda/lib/python3.5/site-packages (python 3.5)
Elenas-MacBook:~ Helen$ pip list DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. absl-py (0.6.1) adal (0.4.5) alabaster (0.7.10) anaconda-clean (1.0) anaconda-client (1.5.1) anaconda-navigator (1.3.1) appdirs (1.4.3) appnope (0.1.0) appscript (1.0.1) argcomplete (1.0.0) asn1crypto (0.22.0) astor (0.7.1) astroid (1.6.4) astropy (1.2.1) azure-batch (2.0.0) azure-common (1.1.4) azure-keyvault (0.1.0) azure-mgmt-batch (3.0.0) azure-mgmt-common (0.20.0) azure-mgmt-compute (0.33.0) azure-mgmt-network (0.30.0) azure-mgmt-nspkg (1.0.0) azure-mgmt-resource (0.31.0) azure-mgmt-storage (0.20.0) azure-nspkg (1.0.0) azure-servicebus (0.20.1) azure-servicemanagement-legacy (0.20.5) azure-storage (0.34.0) Babel (2.5.3) backports.shutil-get-terminal-size (1.0.0) beautifulsoup4 (4.5.1) bitarray (0.8.1) blaze (0.10.1) blobxfer (0.12.1) bokeh (0.12.2) boto (2.48.0) boto3 (1.7.3) botocore (1.10.3) Bottleneck (1.1.0) brewer2mpl (1.4.1) bs4 (0.0.1) bz2file (0.98) certifi (2018.1.18) cffi (1.9.1) chardet (3.0.4) chest (0.2.3) click (6.7) cloudpickle (0.2.1) clyent (1.2.2) colorama (0.3.7) conda (4.5.11) conda-build (2.0.2) configobj (5.0.6) configparser (3.5.0) contextlib2 (0.5.3) cryptography (1.8.1) cssselect (1.0.1) cycler (0.10.0) cymem (1.31.2) Cython (0.24.1) cytoolz (0.8.0) dask (0.11.0) datashape (0.5.2) decorator (4.0.10) dill (0.2.5) dm-sonnet (1.23) docutils (0.14) dynd (0.7.3.dev1) emoji (0.5.0) et-xmlfile (1.0.1) Faker (0.8.13) fastcache (1.0.2) feedfinder2 (0.0.4) feedparser (5.2.1) filelock (2.0.6) Flask (0.11.1) Flask-Cors (2.1.2) flexmock (0.10.2) future (0.16.0) gast (0.2.0) gensim (3.4.0) gevent (1.1.2) ggplot (0.11.5) goose3 (3.0.9) graph-nets (1.0.2) greenlet (0.4.10) grpcio (1.16.0) h5py (2.8.0) HeapDict (1.0.0) html5lib (1.0.1) hyperopt (0.1) idna (2.6) imagesize (1.0.0) ipykernel (4.5.0) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) isodate (0.5.4) isort (4.3.4) itsdangerous (0.24) jdcal (1.2) jedi (0.12.0) jieba (0.39) jieba3k (0.35.1) Jinja2 (2.10) jmespath (0.9.3) json-lines (0.4.0) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.0) Keras (2.0.8) Keras-Applications (1.0.6) Keras-Preprocessing (1.0.5) keyring (10.3) Lasagne (0.2.dev1) lazy-object-proxy (1.3.1) llvmlite (0.13.0) locket (0.2.0) lxml (3.6.4) Markdown (3.0.1) MarkupSafe (1.0) matplotlib (1.5.3) mccabe (0.6.1) mistune (0.7.3) mpmath (0.19) msrest (0.4.6) msrestazure (0.4.7) multipledispatch (0.4.8) murmurhash (0.26.4) nb-anacondacloud (1.2.0) nb-conda (2.0.0) nb-conda-kernels (2.0.0) nbconvert (4.2.0) nbformat (4.1.0) nbpresent (3.0.2) networkx (1.11) newspaper3k (0.2.5) nltk (3.2.1) nose (1.3.7) notebook (4.2.3) numba (0.28.1) numexpr (2.6.1) numpy (1.15.4) numpydoc (0.7.0) oauthlib (2.0.1) odo (0.5.0) opencv-python (3.2.0.6) openpyxl (2.3.2) packaging (17.1) pandas (0.18.1) parso (0.2.0) partd (0.3.6) path.py (0.0.0) pathlib (1.0.1) pathlib2 (2.1.0) patsy (0.4.1) pep8 (1.7.0) pexpect (4.0.1) pickleshare (0.7.4) Pillow (3.3.1) pip (9.0.1) pkginfo (1.3.2) plac (0.9.6) ply (3.9) preshed (0.46.4) prompt-toolkit (1.0.3) protobuf (3.6.1) psutil (5.4.5) ptyprocess (0.5.1) py (1.4.31) pyasn1 (0.1.9) pycodestyle (2.3.1) pycosat (0.6.3) pycparser (2.17) pycrypto (2.6.1) pycurl (7.43.0) pyflakes (2.0.0) Pygments (2.2.0) PyJWT (1.4.2) pylint (1.9.1) pymongo (3.4.0) pyOpenSSL (16.2.0) pyparsing (2.2.0) PySocks (1.6.8) pytest (2.9.2) python-dateutil (2.6.1) pytz (2018.4) PyYAML (3.12) pyzmq (17.0.0) QtAwesome (0.4.4) qtconsole (4.2.1) QtPy (1.4.2) redis (2.10.5) regex (2018.11.22) requests (2.18.4) requests-file (1.4.2) requests-oauthlib (0.8.0) rope-py3k (0.9.4.post1) ruamel-yaml (-VERSION) s3transfer (0.1.13) scattertext (0.0.2.23) scikit-image (0.12.3) scikit-learn (0.19.1) scipy (1.0.1) semver (2.7.5) setuptools (40.5.0) simplegeneric (0.8.1) singledispatch (3.4.0.3) six (1.11.0) sklearn (0.0) smart-open (1.5.7) snowballstemmer (1.2.1) sockjs-tornado (1.0.3) spacy (1.6.0) Sphinx (1.4.6) sphinxcontrib-websupport (1.0.1) sputnik (0.9.3) spyder (3.2.3) SQLAlchemy (1.0.13) statsmodels (0.6.1) sympy (1.0) tables (3.2.3.1) tensorboard (1.12.0) tensorflow (1.12.0) tensorflow-probability (0.4.0) termcolor (1.1.0) terminado (0.6) text-unidecode (1.2) textblob (0.15.1) Theano (0.9.0b1) thinc (6.2.0) tldextract (2.2.0) toolz (0.8.0) tornado (4.4.1) tqdm (4.11.2) traitlets (4.3.0) tweepy (3.6.0) ujson (1.35) unicodecsv (0.14.1) urllib3 (1.22) virtualenv (15.1.0) wcwidth (0.1.7) webencodings (0.5.1) Werkzeug (0.14.1) wheel (0.32.2) widgetsnbextension (1.2.6) wordcloud (1.4.1) wrapt (1.10.11) xgboost (0.7.post4) xlrd (1.0.0) XlsxWriter (0.9.3) xlwings (0.10.0) xlwt (1.1.2) xmltodict (0.10.2)
Elenas-MacBook:~ Helen$ conda list
#
_license 1.1 py35_1
_nb_ext_conf 0.3.0 py35_0
absl-py 0.6.1
anaconda 4.2.0 np111py35_0
anaconda-clean 1.0.0 py35_0
anaconda-client 1.5.1 py35_0
anaconda-navigator 1.3.1 py35_0
appdirs 1.4.3
appscript 1.0.1 py35_0
argcomplete 1.0.0 py35_1
asn1crypto 0.22.0
astropy 1.2.1 np111py35_0
azure 1.0.2 py35_0
azure-batch 1.1.0
backports 1.0 py35_0
beautifulsoup4 4.5.1 py35_0
bitarray 0.8.1 py35_0
blaze 0.10.1 py35_0
blobxfer 0.12.1
boto 2.48.0
boto3 1.7.3
brewer2mpl 1.4.1
certifi 2018.1.18
cffi 1.9.1
chardet 3.0.4
click 6.6 py35_0
click 6.7
clyent 1.2.2 py35_0
colorama 0.3.7 py35_0
conda 4.5.11 py35_0
conda-build 2.0.2 py35_0
conda-env 2.6.0 1
configobj 5.0.6 py35_0
configparser 3.5.0
cryptography 1.8.1
cssselect 1.0.1
cycler 0.10.0 py35_0
cymem 1.31.2
cytoolz 0.8.0 py35_0
dask 0.11.0 py35_0
datashape 0.5.2 py35_0
decorator 4.0.10 py35_0
dill 0.2.5 py35_0
dm-sonnet 1.23
docutils 0.14
emoji 0.5.0
et_xmlfile 1.0.1 py35_0
Faker 0.8.13
feedfinder2 0.0.4
flask 0.11.1 py35_0
flask-cors 2.1.2 py35_0
flexmock 0.10.2
future 0.16.0
gensim 3.4.0
gevent 1.1.2 py35_0
ggplot 0.11.5
grpcio 1.16.0
hdf5 1.8.17 1
heapdict 1.0.0 py35_1
html5lib 1.0.1
idna 2.1 py35_0
idna 2.6
ipykernel 4.5.0 py35_0
ipython 5.1.0 py35_0
ipython_genutils 0.1.0 py35_0
ipywidgets 5.2.2 py35_0
isodate 0.5.4
jbig 2.1 0
jdcal 1.2 py35_1
jedi 0.9.0 py35_1
jedi 0.12.0
Jinja2 2.10
json-lines 0.4.0
jupyter 1.0.0 py35_3
jupyter_client 4.4.0 py35_0
jupyter_console 5.0.0 py35_0
jupyter_core 4.2.0 py35_0
Keras 2.0.8
Lasagne 0.2.dev1
lazy-object-proxy 1.3.1
libpng 1.6.22 0
libtiff 4.0.6 2
libxml2 2.9.2 0
libxslt 1.1.28 2
llvmlite 0.13.0 py35_0
locket 0.2.0 py35_1
lxml 3.6.4 py35_0
Markdown 3.0.1
matplotlib 1.5.3 np111py35_0
mccabe 0.6.1
mkl 11.3.3 0
mkl-service 1.1.2 py35_2
mpmath 0.19 py35_1
msrest 0.4.6
murmurhash 0.26.4
nb_conda 2.0.0 py35_0
nb_conda_kernels 2.0.0 py35_0
nbconvert 4.2.0 py35_0
nbformat 4.1.0 py35_0
nbpresent 3.0.2 py35_0
networkx 1.11 py35_0
newspaper3k 0.2.5
nose 1.3.7 py35_1
notebook 4.2.3 py35_0
numba 0.28.1 np111py35_0
numexpr 2.6.1 np111py35_0
numpy 1.15.4
numpydoc 0.7.0 py35_0
oauthlib 2.0.1
opencv-python 3.2.0.6
openssl 1.0.2j 0
packaging 17.1
parso 0.2.0
path.py 8.2.1 py35_0
pathlib 1.0.1
patsy 0.4.1 py35_0
pep8 1.7.0 py35_0
pexpect 4.0.1 py35_0
pickleshare 0.7.4 py35_0
pillow 3.3.1 py35_0
pip 8.1.2 py35_0
pip 9.0.1
plac 0.9.6
preshed 0.46.4
protobuf 3.6.1
ptyprocess 0.5.1 py35_0
py 1.4.31 py35_0
pyasn1 0.1.9 py35_0
pycodestyle 2.3.1 py35_0
pycosat 0.6.3 py35h745f8c1_0
pycparser 2.17
pycrypto 2.6.1 py35_4
pycurl 7.43.0 py35_0
pyflakes 2.0.0
pygments 2.1.3 py35_0
Pygments 2.2.0
pymongo 3.4.0
pyparsing 2.1.4 py35_0
pyparsing 2.2.0
PySocks 1.6.8
pytest 2.9.2 py35_0
python 3.5.2 0
python-dateutil 2.5.3 py35_0
python-dateutil 2.6.1
pytz 2016.6.1 py35_0
pytz 2018.4
pyzmq 17.0.0
qt 5.6.0 0
qtawesome 0.4.4 py35_0
QtAwesome 0.4.4
QtPy 1.4.2
readline 6.2 2
redis 3.2.0 0
redis-py 2.10.5 py35_0
regex 2018.11.22
requests 2.18.4
ruamel_yaml 0.11.14 py35_0
s3transfer 0.1.13
scikit-learn 0.19.1
scipy 1.0.1
semver 2.7.5
setuptools 40.5.0
singledispatch 3.4.0.3 py35_0
sip 4.18 py35_0
six 1.11.0
six 1.10.0
snowballstemmer 1.2.1 py35_0
sockjs-tornado 1.0.3 py35_0
spacy 1.6.0
sphinxcontrib-websupport 1.0.1
sqlalchemy 1.0.13 py35_0
sqlite 3.13.0 0
statsmodels 0.6.1 np111py35_1
sympy 1.0 py35_0
tensorboard 1.12.0
text-unidecode 1.2
thinc 6.2.0
tldextract 2.2.0
tornado 4.4.1 py35_0
tqdm 4.11.2
tweepy 3.6.0
urllib3 1.22
webencodings 0.5.1
Werkzeug 0.14.1
widgetsnbextension 1.2.6 py35_0
wordcloud 1.4.1
wrapt 1.10.11
xlsxwriter 0.9.3 py35_0
xlwings 0.10.0 py35_0
xlwt 1.1.2 py35_0
xmltodict 0.10.2
yaml 0.1.6 0
zlib 1.2.8 3
Sorry, I can't reproduce this. I've just made a new conda environment where I've tried to reproduce your setup, but it works for me. Can you let me know if the following works for you?
conda create -n issue36 python=3.5.2
conda activate issue36
git clone git@github.com:alan-turing-institute/ReadabiliPy.git
cd ReadabiliPy/
pip install -r requirements-dev.txt
pytest
I have the following versions and paths for the relevant tools:
which python && python --version
> /Users/jrobinson/anaconda3/envs/issue36/bin/python
> Python 3.5.2 :: Continuum Analytics, Inc.
which pip && pip --version
> /Users/jrobinson/anaconda3/envs/issue36/bin/pip
> pip 10.0.1 from /Users/jrobinson/anaconda3/envs/issue36/lib/python3.5/site-packages/pip (python 3.5)
which pytest && pytest --version
> /Users/jrobinson/anaconda3/envs/issue36/bin/pytest
> This is pytest version 4.0.2, imported from /Users/jrobinson/anaconda3/envs/issue36/lib/python3.5/site-packages/pytest.py
Hi,
I have created virtual env, but
git clone git@github.com:alan-turing-institute/ReadabiliPy.git
returns
`Cloning into 'ReadabiliPy'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.`
If I just download the repository and uzip it, then follow your instructions, I get the following:
pip install -r requirements-dev.txt Collecting bs4 (from -r requirements-dev.txt (line 1)) Collecting html5lib (from -r requirements-dev.txt (line 2)) Using cached https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl Collecting pyflakes (from -r requirements-dev.txt (line 3)) Downloading https://files.pythonhosted.org/packages/44/98/af7a72c9a543b1487d92813c648cb9b9adfbc96faef5455d60f4439aa99b/pyflakes-2.0.0-py2.py3-none-any.whl (53kB) 100% |████████████████████████████████| 61kB 215kB/s Collecting pytest (from -r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/19/80/1ac71d332302a89e8637456062186bf397abc5a5b663c1919b73f4d68b1b/pytest-4.0.2-py2.py3-none-any.whl (217kB) 100% |████████████████████████████████| 225kB 313kB/s Collecting regex (from -r requirements-dev.txt (line 5)) Collecting beautifulsoup4 (from bs4->-r requirements-dev.txt (line 1)) Downloading https://files.pythonhosted.org/packages/21/0a/47fdf541c97fd9b6a610cb5fd518175308a7cc60569962e776ac52420387/beautifulsoup4-4.6.3-py3-none-any.whl (90kB) 100% |████████████████████████████████| 92kB 264kB/s Collecting webencodings (from html5lib->-r requirements-dev.txt (line 2)) Using cached https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl Collecting six>=1.9 (from html5lib->-r requirements-dev.txt (line 2)) Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl Collecting more-itertools>=4.0.0 (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/79/b1/eace304ef66bd7d3d8b2f78cc374b73ca03bc53664d78151e9df3b3996cc/more_itertools-4.3.0-py3-none-any.whl (48kB) 100% |████████████████████████████████| 51kB 423kB/s Collecting attrs>=17.4.0 (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl Collecting atomicwrites>=1.0 (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/3a/9a/9d878f8d885706e2530402de6417141129a943802c084238914fa6798d97/atomicwrites-1.2.1-py2.py3-none-any.whl Collecting py>=1.5.0 (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/3e/c7/3da685ef117d42ac8d71af525208759742dd235f8094221fdaafcd3dba8f/py-1.7.0-py2.py3-none-any.whl (83kB) 100% |████████████████████████████████| 92kB 322kB/s Collecting pathlib2>=2.2.0; python_version < "3.6" (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/2a/46/c696dcf1c7aad917b39b875acdc5451975e3a9b4890dca8329983201c97a/pathlib2-2.3.3-py2.py3-none-any.whl Requirement already satisfied: setuptools in /anaconda/envs/readabilipy/lib/python3.5/site-packages (from pytest->-r requirements-dev.txt (line 4)) (40.2.0) Collecting pluggy>=0.7 (from pytest->-r requirements-dev.txt (line 4)) Downloading https://files.pythonhosted.org/packages/1c/e7/017c262070af41fe251401cb0d0e1b7c38f656da634cd0c15604f1f30864/pluggy-0.8.0-py2.py3-none-any.whl Installing collected packages: beautifulsoup4, bs4, webencodings, six, html5lib, pyflakes, more-itertools, attrs, atomicwrites, py, pathlib2, pluggy, pytest, regex Successfully installed atomicwrites-1.2.1 attrs-18.2.0 beautifulsoup4-4.6.3 bs4-0.0.1 html5lib-1.0.1 more-itertools-4.3.0 pathlib2-2.3.3 pluggy-0.8.0 py-1.7.0 pyflakes-2.0.0 pytest-4.0.2 regex-2018.11.22 six-1.12.0 webencodings-0.5.1 You are using pip version 10.0.1, however version 18.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. (readabilipy) Elenas-MacBook:ReadabiliPy-master Helen$ pytest ============================= test session starts ============================== platform darwin -- Python 3.5.2, pytest-4.0.2, py-1.7.0, pluggy-0.8.0 rootdir: /Users/Helen/ReadabiliPy-master, inifile: collected 0 items / 5 errors
==================================== ERRORS ====================================
_ ERROR collecting tests/test_htmlelements.py
ImportError while importing test module '/Users/Helen/ReadabiliPy-master/tests/test_html_elements.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_html_elements.py:3: in
Hi @kochkinaelena . Aha! The top-level directory has to be called ReadabiliPy
not ReadabiliPy-master
as the tests are trying to import things from here. Easiest solution is to unzip the file again into a fresh directory called ReadabiliPy
. By the way, as the ssh clone isn't working for you, perhaps the https one will instead? git clone https://github.com/alan-turing-institute/ReadabiliPy.git
Hi,
Thank you! This has resolved my issue python -m pytest tests
works, however pytest
on its own still doesn't but it doesn't matter too much.
Thanks again for your help.
Best, Elena
Hi,
I have installed everything as explained in readme, no errors, but I get the following when I run testing.
========================================================================================= ERRORS ========================================================================================= ______________________________________________________________________ ERROR collecting tests/test_html_elements.py ______________________________________________________________________ tests/test_html_elements.py:3: in <module> from ReadabiliPy import readability, text_manipulation E ImportError: No module named 'ReadabiliPy' __________________________________________________________________ ERROR collecting tests/test_plain_html_functions.py ___________________________________________________________________ tests/test_plain_html_functions.py:3: in <module> from ReadabiliPy import plain_html E ImportError: No module named 'ReadabiliPy' _______________________________________________________________________ ERROR collecting tests/test_readability.py _______________________________________________________________________ tests/test_readability.py:4: in <module> from ReadabiliPy import readability, text_manipulation E ImportError: No module named 'ReadabiliPy' ____________________________________________________________________ ERROR collecting tests/test_text_manipulation.py ____________________________________________________________________ tests/test_text_manipulation.py:1: in <module> from ReadabiliPy.text_manipulation import normalise_text E ImportError: No module named 'ReadabiliPy' ================================================================================ 4 error in 0.55 seconds