Unable to troubleshoot Pip setup

Hey y’all,
I’ve been trying to get my workspace set up to begin making my cs101 portfolio project.
This is the lesson in which they teach you how to set up pip:
I’m able to follow along until around 20:20 when the problems crop up.

I’ve been able to install pip, create folders and files (the pip files and pip.lock files), as well as install modules (numpy), but when I attempt to run ‘pipenv shell’ instead of the terminal switching to Python like in the video it changes to pipenv. From this point on I’m unable to follow along as the subsequent commands such as ‘import numpy’ or ‘print(numpy.version)’ returns

File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

I’ve spent at least 5 hours trying to slog through tutorials to find what I’ve done wrong. The only relevant help I’ve found was someone saying to uninstall Python and pip and re-install them (making sure Python’s path option is ticked). While I was able to re-install Python, when I attempt to uninstall pip I get this error:

Found existing installation: pip 21.2.4
WARNING: Value for bin_prefix does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
distutils: C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\bin
sysconfig: C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Scripts
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Uninstalling pip-21.2.4:
  Would remove:
    c:\program files\windowsapps\pythonsoftwarefoundation.python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip-21.2.4.dist-info\*
    c:\program files\windowsapps\pythonsoftwarefoundation.python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\*
Proceed (Y/n)? y
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 815, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\windowsapps\\pythonsoftwarefoundation.python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\\lib\\site-packages\\pip-21.2.4.dist-info\\' -> 'C:\\Users\\Houston\\AppData\\Local\\Temp\\pip-uninstall-817lt_6t'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\commands\uninstall.py", line 93, in run
    uninstall_pathset = req.uninstall(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\req\req_install.py", line 633, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\req\req_uninstall.py", line 384, in remove
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\req\req_uninstall.py", line 281, in stash
    renames(path, new_path)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\utils\misc.py", line 331, in renames
    shutil.move(old, new)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 833, in move
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 749, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 627, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 625, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\windowsapps\\pythonsoftwarefoundation.python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\\lib\\site-packages\\pip-21.2.4.dist-info\\entry_points.txt'

I frankly have no clue what I am doing. I just want to get this sorted so I can actually write code.
Thank you for your time!

hi @tanakaido try running your terminal with Administrator privilege on your Windows computer. Then run the respective commands to see if is possible.

By running with “Run as administrator”

The paths are different. You need to uninstall pip from the env python not the system’s python.

Maybe this would help?:

This also might help explain virtual environments (you can set up several with different versions of python–depending on whatever your projects needs are).


And this:

Hello again!
Thank you for the advice, I re-installed python and learned how to set up virtual environments using both the Install Python 3.8, Virtual Environments using Pipenv, Django 3+ on Windows // Blog // Coding for Entrepreneurs and Install Python 3.8 on Windows 10 - 4 of 10 - Create and Activate a Virtual Environment with Pipenv - YouTube provided.
Unfortunately the main issue I had before is still unresolved, that being the ModuleNotFoundError.
Below is a screenshot and the terminal output showing a project with numpy installed,

Houston@DESKTOP-20OO2FL MINGW64 ~/Dev/cfehome
$ ls
deactivate  Pipfile  Pipfile.lock

Houston@DESKTOP-20OO2FL MINGW64 ~/Dev/cfehome
$ pipenv shell
Launching subshell in virtual environment...

Houston@DESKTOP-20OO2FL MINGW64 ~/Dev/cfehome
$ pip freeze

Houston@DESKTOP-20OO2FL MINGW64 ~/Dev/cfehome
$ python3
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

I can only assume that the cause of this error is incorrect pathing as I’ve been able to set everything up fine according to the tutorials.
Python is stored here: C:\Python310
and my projects are stored here: C:\Users\Houston\Dev\cfehome

Once again, any advice is appreciated.
Thank you for your time!

If you have NumPy installed in a global environment, then you cannot use it/access it in a virtual environment b/c is has a different/separate package management.

Did you try pip install numpy in that particular environment?


1 Like

Thank you for your help Lisa!
The cause of the problem was vs code’s interpreter using the wrong version of python, all I had to do was change it from an outdated version.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.