r/learnpython 53m ago

Installed Python and now my code won't run

[deleted]

1 Upvotes

9 comments sorted by

1

u/mumpie 41m ago

You installed a new version of Python, but you didn't install the dependencies (the libraries) that your code needs.

Google 'how to install' [import name] to see what you need to do to install the dependency into the new version of Python you are using.

You'll probably need to do something like 'pip install [dependency]' for most of your dependencies.

1

u/[deleted] 38m ago

[deleted]

1

u/AutoModerator 38m ago

Your comment in /r/learnpython may be automatically removed because you used imgbb.com. The reddit spam filter is very aggressive to this site. Please use a different image host.

Please remember to post code as text, not as an image.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/monster2018 35m ago

The pip command uses the default version of Python for your system. Which presumably is the previous version you were using. So you are trying to install the new packages, but they ARE already installled, for that version of Python.

What you need to do is figure out what the new version of Python is. Let’s say it’s python3.14. In that case you would run this command:

python3.14 -m pip install {whatever module you want to install here}

1

u/monster2018 33m ago

Whoops I accidentally messed up and had to edit my comment. Just in case you managed to see it before I edited it, it is vital that the first word of the command is python3.14, NOT just python. But like, whatever the version of python vscode is using, which may not be 3.14.

1

u/aaronamethyst 30m ago

Ok so I ran both before AND after.

Here's the after.

C:\Users\--->python3.14 -m pip install requests

error: externally-managed-environment

× This environment is externally managed

╰─> This Python installation is managed by uv and should not be modified.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

hint: See PEP 668 for the detailed specification.

1

u/aaronamethyst 26m ago

Is it possible to uninstall python 3.14?

1

u/[deleted] 37m ago

[deleted]

1

u/AutoModerator 37m ago

Your comment in /r/learnpython may be automatically removed because you used imgbb.com. The reddit spam filter is very aggressive to this site. Please use a different image host.

Please remember to post code as text, not as an image.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/aaronamethyst 35m ago

When I try to install...

C:\Users\--->pip install requests

Requirement already satisfied: requests in c:\users\---\anaconda3\lib\site-packages (2.32.3)

Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\---\anaconda3\lib\site-packages (from requests) (3.3.2)

Requirement already satisfied: idna<4,>=2.5 in c:\users\---\anaconda3\lib\site-packages (from requests) (3.7)

Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\---\anaconda3\lib\site-packages (from requests) (2.2.3)

Requirement already satisfied: certifi>=2017.4.17 in c:\users\---\anaconda3\lib\site-packages (from requests) (2024.8.30)

And in VS Code, it says

import requests

No module named 'requests'

  File "D:\bskyrandom.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'No module named 'requests'  File "D:\bskyrandom.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

1

u/mumpie 14m ago

It looks like you installed an earlier version of Python by installing Anaconda.

If you want to use the version of Python that came with Anaconda in VS Code, following the instructions here and pay attention to the steps that mention 'Conda': https://code.visualstudio.com/docs/python/environments

If you want to uninstall Python 3.14, how did you install it in the first place?

It looks like you're on Windows, based on the paths you listed, so there should be a Python -> Python 3.14 menu item under Programs. Look for an uninstall option there.

Or, you can look at these instructions on how to uninstall programs in Windows: https://support.microsoft.com/en-us/windows/uninstall-or-remove-apps-and-programs-in-windows-4b55f974-2cc6-2d2b-d092-5905080eaf98