16

I am following the following link to install RASA on my system: https://github.com/RasaHQ/rasa But unfortunately while trying to install the dependencies or any of the following poetry commands which are written in Makefile,

$poetry run
$poetry install

I am getting following error:

enter image description here

Seems like there is some issue in virtual environment setup but don't know how I can fix. Following is the stack trace:

$ make install
poetry run python -m pip install -U 'pip<20'
The virtual environment found in /home/kamaldeep/.cache/pypoetry/virtualenvs/rasa-LHgLSZoI-py3.6 seems to be broken.
Recreating virtualenv rasa-LHgLSZoI-py3.6 in /home/kamaldeep/.cache/pypoetry/virtualenvs/rasa-LHgLSZoI-py3.6

[CalledProcessError]
Command '['/home/kamaldeep/.cache/pypoetry/virtualenvs/rasa-LHgLSZoI-py3.6/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
Makefile:43: recipe for target 'install' failed
make: *** [install] Error 1
Kamaldeep Singh
  • 765
  • 2
  • 8
  • 28

5 Answers5

6

Kamaldeep Singh's answer was what I needed: sudo apt-get install python3.7-venv. (adjust for your particular Python 3.x version etc)

A couple of details to add to complete the process (this is for those like me who aren't so comfortable juggling package versions and are also perhaps new to using Poetry) (adjust for the Python version you want to work with):

  • Go to your project directory and start Poetry (if you're not already there); get rid of the broken virtual environment,

     cd your_project_directory
     poetry shell
     poetry env remove python3.7
    
  • Leave Poetry (I found Poetry got muddled otherwise),

     exit
    
  • Did you already install python3.7-venv as per Kamaldeep Singh's answer? Do it now if not (assuming you're on a Debian/Ubuntu-based system),

     sudo apt install python3.7-venv
    
  • Re-enter Poetry,

     poetry shell
    
  • Recreate the environment now that python3.7-venv is installed,

     poetry env use python3.7
    
  • Add required dependencies for your project,

     poetry install
    

That's it, you should now be ready to work on your project in the new Python version. Poetry CLI documentation for more options...

(update: One bit of strangeness: I found exiting and re-entering poetry shell one more time after poetry install was necessary for pytest to be found. This leave Poetry and re-enter it step (again) feels very clumsy, maybe someone here can explain why that might be necessary in comments?)

Andrew Richards
  • 1,392
  • 11
  • 18
5

In case if you get error of broken virtual environment like

The virtual environment found in /home/kamaldeep/.cache/pypoetry/virtualenvs/rasa-LHgLSZoI-py3.7 seems to be broken

Then install venv in the respective python package like python3.6, python3.5. In my case, I am using python 3.7

sudo apt-get install python3.7-venv

Other way is to disable virtual environment

poetry config virtualenvs.create false
Kamaldeep Singh
  • 765
  • 2
  • 8
  • 28
  • 4
    Using Poetry to not "create" virtual envs seems counterintuitive to me. Can you elaborate on why I would do that? – Jarmos May 21 '20 at 05:28
  • Saved my day with sudo apt-get install python3.7-venv Thanks – deMangler May 30 '20 at 13:11
  • 4
    @Jarmos. For example, if you want to make a ci pipeline where a docker python image is used, python base in docker can be your environment directly and be used only as a mean to packatize with poetry – Antonio Andrés Sep 08 '20 at 13:31
  • I run `poetry config virtualenvs.create false` inside my conda env... It delete my conda env !!! – Jackiexiao Aug 17 '21 at 03:06
0

With poetry issues like that, it is sometimes easiest to delete the poetry-created virtual environment and re-run make install so that it starts fresh.

Melinda
  • 747
  • 5
  • 13
  • which branch of the repo are you trying to install? Try installing one of the tags (e.g. `git checkout` 1.9.6, then try to install). If it's due to a specific branch being unstable/changing that could be the problem – Melinda Apr 23 '20 at 13:51
0

Probably the python version installed on your host machine does not correspond to the project requirements.

You can overcome that by first setting up an virtual environment using virtualenv ou pyenv.

Example:

cd <your-project-folder>
virtualenv env -p python3.8
source env/bin/activate  

and finally

$ poetry install
Slipstream
  • 13,455
  • 3
  • 59
  • 45
-1

By mindful of the underlying file structure too!

I had a VScode terminal open, even after I had renamed the folder under which the terminal was open at. The terminal had kept the previous folder name and poetry was complaining with the exact same message as above, that was misleading and always the same regardless of how many times I recreated my .venv

All I had to do was to cd ../new_folder_name and recreate the .venv again.

stratosgear
  • 942
  • 1
  • 16
  • 37