#🔒 Python-chess refuses to download for me
95 messages · Page 1 of 1 (latest)
@tall oak
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!pypi chess
Is this the library you're trying to install? @tall oak
When you run pip install chess what happens
here's the exact code: Requirement already satisfied: chess in c:\users(my_name)\appdata\local\programs\python\python313\lib\site-packages (1.11.2)
So you've already installed it?
apparently
Does it work when you run your code
Do you get an error when you run your code or is it just a warning from vsc of unused import
this is the error I get when running the code:
ModuleNotFoundError: No module named 'chess'
Ah okay
You most likely have multiple python versions installed. You must've installed the package to one python version and you're running your code in another version
The recommended way to use virtual environments to fix this
!venv
Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.
To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)
Then, to activate the new virtual environment:
Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate
Packages can then be installed to the virtual environment using pip, as normal.
For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.
Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.
Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
I installed it in the VScode control terminal
Yes
This what happened when you installed it
And why it's not working
alright
give me a minute to read what you sent me
so, do you want me to do the pip install inside the venv? @lost burrow
Yeah, first activate the venv and then run the pip install commands
You'll have to re install your other dependancies too
so I'm pretty much working in a blank python file rn. I wrote import venv, ran the code, which (for lack of understanding of this command) made the terminal look slightly different, then I did the pip install inside of the slightly different terminal, and got the exact same result: Requirement already satisfied
Can you show a screenshot of your entire vsc with the terminal open
See that when vscode runs your script it's invoking 3.12? And that pip installs to 3.13?
I see that now. I should only have 3.12 on my machine though
You want to run pip for the python you're using to run your code.
We normally suggest:
```sh
python -m pip install chess
replacing `python` with the python running your script. So maybe,
```sh
py -3.12 -m pip install chess
```
i.e. py -3.12 to get the python launcher to use 3.12.
Or copy/paste the executable vscode is using:
```sh
C:......312...\python.exe -m pip install chess
like this?
I'd suggest using venv and making vsc select that venv for the project. It makes things much easier in the long run as they wouldn't need to type out that entire thing next time they try to install
If you make a venv you can (a) tell vscode to use it and (b) run the activate script in the terminal window, which should make things use that python.
Sorry, no.
py -3.12 -m pip install chess
Note the -m before pip
So we're replacing python with py -3.12 to specify the python.
Then using the pip module from that specific python.
Thus installing for that specific python.
got this error
py : The term 'py' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
- py -3.12 -m pip install chess
- ~~
- CategoryInfo : ObjectNotFound: (py:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
I believe I'm not in the right file location
No py command? I presume py -0 doesn't do anything useful either?
Shouldn't really matter.
You might have not set python to path
this would be a lot easier if I could share my screen with you two
What about copying vscodes long path-to-the-python.exe ? That should work.
I gotta head out for my uni soon
And I'm supposed to be working 🙁
:(
what do you mean?
vscode is invoking the 3.12 python. Which is fine.
Just copy/paste its long C:....python.exe path as the python command.
```sh
C:......312....\python.exe -m pip install chess
I can't copy paste tfrom a screenshot, so the above is merely a sketch of the path.
You should probably just set python to path manually
If you can describe what that means, go ahead.
If you open the environments app on windows and add the python exe path to the registry there, you will be able to invoke python normally
Wait
@tall oak did you install python from ms store?
no
Unknown option: -0
usage: C:\Users\zgawi\AppData\Local\Programs\Python\Python312\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
Okay..
wait, - capitol o worked
Python 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Ctrl click to launch VS Code Native REPL
Well that's not what I wanted but it's okay
Well it's wierd that you use python instead of py by default
-0 is for the py python launcher
which they don't seem to have
Unless youve installed from Ms store
```sh
C:\Users\zgawi\AppData\Local\Programs\Python\Python312\python.exe -m pip install chess
I gotta head out now
cya
me too
see if the above does the install.
It's long and tedious, but matches the python vscode is invoking.
You only need it for the pip install.
I do not think it did
wait, I reloaded vscode and am no longer getting an error
:warning: The owner of this post is no longer in the server.
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.