justinmayer / virtualfish

Fish shell tool for managing Python virtual environments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

update_python plugin: Erroneous error when updating a virtualenv which has nothing installed

adamtheturtle opened this issue · comments

  • I am using Fish shell version 3.1 or higher.
  • I am using Python version 3.6 or higher.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • If related to a plugin, I prefixed the issue title with the name of the plugin.
  • OS version and name: macOS 10.15.5
  • Fish shell version: 3.1.2
  • VirtualFish version: 2.3.0

Issue

I created a virtualenv using VirtualFish.

I did not install anything with pip.

Later, I enabled the update_python plugin.

I ran update_python.

I see ERROR: You must give at least one requirement to install (see "pip help install").

I expect that there would be no such error.

I would expect that error given the circumstances. What exactly were you trying to achieve?

The purpose of the update_python plugin, as I understand it anyway, is to migrate an existing virtual environment to a newer version of Python. It does that by running pip freeze, creating a new virtual environment, and then Pip-installing the frozen requirements into the new virtual environment. If you don't have any packages installed in your virtual environment, then there is nothing to migrate.

Thank you for the quick response.

I wanted to pip install --upgrade pip in all of my virtualenvs.

Some of those virtualenvs showed:

dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/adam/.virtualenvs/auto_ex/bin/python3.8
  Reason: image not found

(or very similar).

I then thought to use update_python essentially to remove that error from each virtualenv.

I then ran update_python on each virtualenv and got this error.

What is confusing is that it ends with an error, but appears that everything has worked: I now have a virtualenv with an updated Python and the same requirements installed (i.e. no requirements).

If the command were called migrate_requirements_to_new_python or similar I wouldn't have opened this.

I didn't write this plugin, but I think the existing docs are fairly clear on this topic. If the Python binary is no longer present (e.g., which happens after brew upgrade python), then update_python may not be what you want. The fix_python command, on the other hand, might be more appropriate. But even that may not behave as you expect if the Python executable is gone.

For further discussion, see: #141. If you'd like to chip in and help implement a better solution for this condition, your assistance would be most helpful.

I added a check that will skip the pip install $packages step if the virtual environment has no$packages installed.

Thank you @justinmayer ! I'm sorry I didn't chip in.