ReviewNB / treon

Easy to use test framework for Jupyter Notebooks
https://reviewnb.com
MIT License
305 stars 29 forks source link

ModuleNotFoundError when using `! pip install <package> #18

Closed alexandreCameron closed 4 years ago

alexandreCameron commented 4 years ago

Hi,

I quickly tested your package today with a notebook call draft-treon.ipynb with the following cell:

! pip install pandas
import pandas as pd

and ran the command:

pip install treon
treon draft-treon.ipynb

But I got the following error message

Executing treon version 0.1.3
Triggered test for draft-treon.ipynb
ERROR in testing draft-treon.ipynb

An error occurred while executing the following cell:
------------------
! pip install pandas

import pandas as pd
------------------

---------------------------------------------------------------------------
ModuleNotFoundError
Traceback (most recent call last)
<ipython-input-1-0da7781ded87> in <module>()
      1 get_ipython().system(' pip install pandas')
      2
----> 3 import pandas as pd

ModuleNotFoundError: No module named 'pandas'
ModuleNotFoundError: No module named 'pandas'

-----------------------------------------------------------------------
TEST RESULT
-----------------------------------------------------------------------
draft-treon.ipynb       -- FAILED 
-----------------------------------------------------------------------
0 succeeded, 1 failed, out of 1 notebooks tested.
-----------------------------------------------------------------------

What would be the correct procedure to run the test ?

Thanks,

amit1rrr commented 4 years ago

@alexandreCameron I ran this exact example in a brand new environment & it succeeds. treon execution installs the pandas package & import works as expected.

I'd check couple of things,

alexandreCameron commented 4 years ago

@amit1rrr :

Can you check if draft-treon.ipynb is saved correctly? get_ipython().system(' pip install pandas') statement in the log looks a bit unfamiliar to me.

I confim the file is saved properly. But I should mention I'm running the code in windows WSL (corporate computer).

Are you using virtualenv / condaenv etc.? Does the cmd line environment where you are running treon has all the necessary permissions to pip install packages?

I'm using a virtualenv, all the permission are OK, and when performing pip freeze in the virtualenv I can see the pandas package.

As a last resort, can you manually run the pip install step and see if the import succeeds?

I can run ! pip install pandas in the notebook without error message and the package is up and running.


The problem could be related to WSL or another corporate security layer on my computer. But I did see where it occurs. I won't feel offended if you close the issue.

merrcury commented 4 years ago

@amit1rrr Please Close this issue. I have performed the same step & It succeeded. Alex was also able to locate the issue.

amit1rrr commented 4 years ago

Thanks, closed. What was the issue? It might help someone else running into the same problem.