#๐Ÿ”’ Is this venv usable

24 messages ยท Page 1 of 1 (latest)

toxic sapphire
#

the one venv was created in a long path, the other on in a short path. The creation on the long paths exited with error code 267, is it still usuable or not because of all the missing files?

lime anchorBOT
#

@toxic sapphire

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.

steady beacon
#

yeah, that test venv in the long path is definitely not usable.

#

error code 267 in windows usually means ERROR_DIRECTORY, which basically implies the system stumbled over the path name or couldn't access the directory properly during the build process.

toxic sapphire
#

so python does not support long paths and there is no way i can create a long path venv?

steady beacon
#

python does support long paths

#

only if the entire ecosystem (the OS, the registry, and the specific API calls) is perfectly aligned.

toxic sapphire
#

well but my prgoram is long paths aware and LongPathsEnable=1 but it still fails

#

powershell is also long paths aware but it also fails in powershell

steady beacon
#

when you run python -m venv, it does this:

creates the folders (this works because mkdir is long-path aware).

copies python.exe (works).

the fail point: it tries to run the newly copied python.exe with the working directory set to your deep Scripts or Lib folder to install pip.

toxic sapphire
#

ah

steady beacon
#

you can try creating the venv without the initial pip install:
python -m venv my_path_env --without-pip

#

this might succeed because it skips the extra process calls

toxic sapphire
#

but i do need to run python.exe -m pip install <things> on the python.exe in the venv

steady beacon
#

if you don't need to run pip or any subprocesses inside that deep directory, you're technically fine, but that venv is still dead on arrival as a standard environment.

#

if python -m venv exits with an error code, it stops execution immediately

toxic sapphire
#

oh sorry i misstyped, i do need python.exe -m pip install <things>

#

if it does not work then i can not allow a long path as cli argument for my program

steady beacon
#

i think i found a fix that shortens the path for the OS:

subst X: "C:\very\long\path\to\project"
X:
python -m venv .venv
#

once you're done, you can subst /d X: to remove the drive.

toxic sapphire
#

hmm thank you. that is actually pretty good, then i can revert eveything back to my logic where i set the working directory and just set it to the drive, which then works because it is short. i just have to scan which drive name is available and give an error if the user wants it to be created at a long paths but has already 26 drives

#

thank you

lime anchorBOT
#
Python help channel closed using Discord native close action

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.