Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipx does not copy site-packages in venvs when installing, resulting in error "No module named pip" #888

Closed
Klemet opened this issue Aug 22, 2022 · 10 comments

Comments

@Klemet
Copy link

Klemet commented Aug 22, 2022

Describe the bug

When trying to install any package with pipx, a pip error is thrown and a log created. The error is No module named pip.

By digging and little and reproducing the commands that pipx uses (present in the log), I realized that during the installation, pipx correctly created the venvs folder for the package that it was trying to install; however, the Lib/site-packages of the venvs folder is empty.

Therefore, as the folder does not contain the pip package files, the installation throws an error when trying to use the command C:\Users\<USER NAME>\.local\pipx\venvs\pycowsay\Scripts\python.exe -m pip install <PACKAGE NAME>.

How to reproduce

  • Fresh installation of Windows 10
  • Installation of Python 3.10.6 and of Anaconda (but making sure that pipx is installed with Python and not Anaconda, and correctly points to the Python installation)
  • Use the command pipx install <PACKAGE NAME>

Expected behavior

The installation process should properly copy the necessary files in venvs/<PACKAGE NAME>/Lib/site-packages, making the command C:\Users\<USER NAME>\.local\pipx\venvs\pycowsay\Scripts\python.exe -m pip install <PACKAGE NAME> succeed and the installation completed.

Workaround

It is possible to create the folder venvs/<PACKAGE NAME>/Lib/site-packages in advance of using the command pipx install <PACKAGE NAME>, and to fill it with the files and folders present in C:\Users\<USER NAME>\.local\pipx\shared\Lib\site-packages.

If this is done, using the command pipx install <PACKAGE NAME> --force will complete the installation of the package properly.

Potential causes

  • Problem with Anaconda installation ? There's not reference to it in the pipx files, but who knows ?
  • I've installed a number of security tweaks and scripts with Windows 10. Maybe some of them are preventing pipx from copying the files properly ? But pipx is still able to create some folders and copy some files when attempting the installation; it's just the files in venvs/<PACKAGE NAME>/Lib/site-packages that are missing.
@znd4
Copy link

znd4 commented Sep 25, 2022

@meowmeowmeowcat, does this fix solve this? (it did for me, albeit on MacOS)

remove ~/.local/pipx/shared

@dukecat0
Copy link
Member

@Klemet Could you try to remove C:\Users\<USER NAME>\.local\pipx\shared and see if it works?

@znd4
Copy link

znd4 commented Sep 26, 2022

🤦 sorry, pinged the wrong person

@d-k-bo
Copy link

d-k-bo commented Oct 4, 2022

I had the same issue after upgrading to Fedora 37 (which updated the main Python installation from 3.10 to 3.11.0rc2). Removing ~/.local/pipx/shared and pipx reinstall-all solved the problem. Thank you!

@Klemet
Copy link
Author

Klemet commented Oct 4, 2022

@meowmeowmeowcat , sorry for being late to respond !

Removing C:\Users\<USER NAME>\.local\pipx\shared was one of my first guesses; by sadly, it has not effect for me. pipx simply re-downloads the shared libraries, and the error happens again. See the output of my powershell below:

PS C:\Windows\System32> pipx install pycowsay
Fatal error from pip prevented installation. Full pip output in file:
    C:\Users\Klemet\.local\pipx\logs\cmd_2022-10-04_13.42.35_pip_errors.log

Error installing pycowsay.


PS C:\Windows\System32> Remove-Item "C:\Users\Klemet\.local\pipx\shared"

Confirm
The item at C:\Users\Klemet\.local\pipx\shared has children and the Recurse parameter was not specified. If you
continue, all children will be removed with the item. Are you sure you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y


PS C:\Windows\System32> pipx install pycowsay
Fatal error from pip prevented installation. Full pip output in file:
    C:\Users\Klemet\.local\pipx\logs\cmd_2022-10-04_13.44.35_pip_errors.log

Error installing pycowsay.
PS C:\Windows\System32>

The resulting pip logs still contain the same error.

@lgibson02
Copy link

I had the same issue after upgrading to Fedora 37 (which updated the main Python installation from 3.10 to 3.11.0rc2). Removing ~/.local/pipx/shared and pipx reinstall-all solved the problem. Thank you!

You are the best. Thank you so much.

@ThisNekoGuy
Copy link

I experienced this problem on Arch Linux as well (mentioning because the issue is only tagged Windows)

@dukecat0
Copy link
Member

dukecat0 commented Mar 18, 2023

Actually I just experienced it on macOS as well. 😄

@Klemet Could you try to remove C:\Users\<USER NAME>\.local\pipx? (If some packages were installed, you can export them by running pipx list --json > pipx_packages.json.)

@dukecat0 dukecat0 removed the windows label Mar 18, 2023
@Klemet
Copy link
Author

Klemet commented Mar 19, 2023

Well, I wanted to delete C:\Users\<USER NAME>\.local\pipx and to see if it fixed everything as you proposed, @meowmeowmeowcat ; but before doing that, I wanted to be sure that the problem was still there.

But now, everything seems to work ! I did not even delete C:\Users\<USER NAME>\.local\pipx, but every package now installs well. I haven't done much to change anything to pipx since, so maybe an update of some kind fixed the problem for me...?

Sorry if that makes it more difficult to find out what the problem was. I'm very surprised.

@gaborbernat
Copy link
Contributor

I had the same issue after upgrading to Fedora 37 (which updated the main Python installation from 3.10 to 3.11.0rc2). Removing ~/.local/pipx/shared and pipx reinstall-all solved the problem. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants