#🔒 Python-chess refuses to download for me

95 messages · Page 1 of 1 (latest)

full mesaBOT
#

@tall oak

Python help channel opened

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.

lost burrow
#

!pypi chess

full mesaBOT
#

A chess library with move generation and validation, Polyglot opening book probing, PGN reading and writing, Gaviota tablebase probing, Syzygy tablebase probing, and XBoard/UCI engine communication.

Released on <t:1740510627:D>.

lost burrow
#

Is this the library you're trying to install? @tall oak

lost burrow
#

When you run pip install chess what happens

tall oak
#

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)

lost burrow
#

So you've already installed it?

tall oak
#

apparently

lost burrow
#

Does it work when you run your code

tall oak
#

when I type "import chess" in VScode, it fails

#

other imports work fine

lost burrow
tall oak
#

this is the error I get when running the code:

#

ModuleNotFoundError: No module named 'chess'

lost burrow
#

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

full mesaBOT
#
Virtual environments

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
tall oak
#

I installed it in the VScode control terminal

lost burrow
#

Yes

lost burrow
#

And why it's not working

tall oak
#

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

lost burrow
#

Yeah, first activate the venv and then run the pip install commands

#

You'll have to re install your other dependancies too

tall oak
#

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

lost burrow
#

Can you show a screenshot of your entire vsc with the terminal open

tall oak
lost burrow
lost burrow
# tall oak

Also I need to see the bar right below the terminal too

somber heron
# tall oak

See that when vscode runs your script it's invoking 3.12? And that pip installs to 3.13?

tall oak
somber heron
#

You want to run ⁨pipfor 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

tall oak
#

like this?

lost burrow
#

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

somber heron
#

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.

somber heron
#

py -3.12 -m pip install chess

#

Note the ⁨-m⁩ before ⁨pip

tall oak
#

got it

#

I think'

somber heron
#

So we're replacing ⁨python⁩ with ⁨py -3.12⁩ to specify the python.

#

Then using the ⁨pipmodule from that specific python.

#

Thus installing for that specific python.

tall oak
#

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

somber heron
#

No ⁨py⁩ command? I presume ⁨py -0⁩ doesn't do anything useful either?

somber heron
lost burrow
#

You might have not set python to path

tall oak
#

this would be a lot easier if I could share my screen with you two

somber heron
#

What about copying vscodes long path-to-the-python.exe ? That should work.

lost burrow
somber heron
#

And I'm supposed to be working 🙁

tall oak
#

:(

somber heron
#

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.

lost burrow
#

You should probably just set python to path manually

somber heron
#

This path

somber heron
lost burrow
#

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?

tall oak
#

no

lost burrow
#

oh okay

#

See if using python -0 works

tall oak
#

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.

lost burrow
#

Okay..

tall oak
#

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

lost burrow
#

Well that's not what I wanted but it's okay

#

Well it's wierd that you use python instead of py by default

somber heron
#

which they don't seem to have

lost burrow
#

Unless youve installed from Ms store

somber heron
#

⁨```sh
C:\Users\zgawi\AppData\Local\Programs\Python\Python312\python.exe -m pip install chess

lost burrow
#

I gotta head out now

tall oak
#

cya

somber heron
#

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.

tall oak
#

wait, I reloaded vscode and am no longer getting an error

full mesaBOT
#

:warning: The owner of this post is no longer in the server.

full mesaBOT
#
Python help channel closed for inactivity

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.