The virtual environment found seems to be broken | python poetry
Asked Answered
L

5

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
Lead answered 21/4, 2020 at 19:30 Comment(1)
Did you run just make install, or poetry run poetry install then make install?Hosbein
G
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?)

Gloriane answered 27/7, 2020 at 14:39 Comment(0)
L
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
Lead answered 23/4, 2020 at 12:11 Comment(4)
Using Poetry to not "create" virtual envs seems counterintuitive to me. Can you elaborate on why I would do that?Carouse
Saved my day with sudo apt-get install python3.7-venv ThanksMoises
@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 poetryUncial
I run poetry config virtualenvs.create false inside my conda env... It delete my conda env !!!Catenate
H
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.

Hosbein answered 22/4, 2020 at 19:31 Comment(1)
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 problemHosbein
A
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
Airscrew answered 24/6, 2020 at 23:40 Comment(1)
This actually helped to make poetry install work on my Monterey 12.5 machineJenness
T
-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.

Tribesman answered 17/10, 2020 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.