question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows embeddable throws FileNotFoundError

See original GitHub issue

Issue

Using the latest (20.15.0) version of virtualenv together with python 3.9 Windows embeddable package throws a FileNotFoundError if calling any module code e.g. python.exe -m virtualenv testEnv.

While following the issue Windows embedable support #1774 and the depending MR Windows embedable support i though it should now be possible to create and handle any venv with a windows embeddable python, but after proceeding the mentioned steps i was still not able to use the virtualenv module. Am i missing any step?

I unzipped the embedded package: https://www.python.org/ftp/python/3.9.13/python-3.9.13-embed-amd64.zip Then I run the get-pip.py: https://bootstrap.pypa.io/get-pip.py Then I uncomment in python39._pth the import statement. Then I add some path to PATH env variable. (add path to python.exe and pip.exe) Then I run pip install virtualenv. Then I tried to call python.exe -m virtualenv testEnv

Note: the unzipped python folder does not contain any DLLs subfolder.

(Tested with latest python 3.9 and 3.10.)

Environment

Provide at least:

  • OS:
C:\Users\tester\Downloads\python-3.9.13-embed-amd64>systeminfo

Host Name:                 WIN10
OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.19043 N/A Build 19043
OS Manufacturer:           Microsoft Corporation
...
  • pip list of the host python where virtualenv is installed:
C:\Users\tester\Downloads\python-3.9.13-embed-amd64>python -m pip list
Package      Version
------------ -------
distlib      0.3.4
filelock     3.7.1
pip          22.1.2
platformdirs 2.5.2
setuptools   62.6.0
six          1.16.0
virtualenv   20.15.0
wheel        0.37.1

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:


C:\Users\tester\Downloads\python-3.9.13-embed-amd64>python.exe -m virtualenv testENV --vvv --with-traceback
Traceback (most recent call last):
  File "runpy.py", line 197, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\__main__.py", line 80, in <module>
    run_with_catch()  # pragma: no cov
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\__main__.py", line 65, in run_with_catch
    run(args, options, env)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\__main__.py", line 18, in run
    session = cli_run(args, options, env)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\run\__init__.py", line 30, in cli_run
    of_session = session_via_cli(args, options, setup_logging, env)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\run\__init__.py", line 48, in session_via_cli
    parser, elements = build_parser(args, options, setup_logging, env)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\run\__init__.py", line 74, in build_parser
    CreatorSelector(interpreter, parser),
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\run\plugin\creators.py", line 15, in __init__
    creators, self.key_to_meta, self.describe, self.builtin_key = self.for_interpreter(interpreter)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\run\plugin\creators.py", line 25, in for_interpreter
    meta = creator_class.can_create(interpreter)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\create\via_global_ref\builtin\via_global_self_do.py", line 34, in can_create
    cls._sources_can_be_applied(interpreter, meta)
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\create\via_global_ref\builtin\via_global_self_do.py", line 39, in _sources_can_be_applied
    for src in cls.sources(interpreter):
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\create\via_global_ref\builtin\cpython\cpython3.py", line 67, in sources
    for ref in refs:
  File "C:\Users\tester\Downloads\python-3.9.13-embed-amd64\lib\site-packages\virtualenv\create\via_global_ref\builtin\cpython\cpython3.py", line 98, in dll_and_pyd
    for file in folder.iterdir():
  File "pathlib.py", line 1160, in iterdir
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\tester\\Downloads\\python-3.9.13-embed-amd64\\DLLs'

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
reksarcommented, Jun 27, 2022

Creating an empty DLLs folder should fix the issue.

1reaction
reksarcommented, Jun 28, 2022

If you know what you do and it just works - why not?

Most use-cases is simple and portable Python environment. I think closest alternative is PyPy (if you don’t pay attention that this is not CPython), but nuget Python package can be too. But both of these alternatives have stdlib venv module, while embedded Python does not. And only virtualenv can help in this case.

Using pip to manage dependencies as for a regular Python installation is not supported with this distribution

but we make pip work

It’s worth pointing out that the embedded distribution doesn’t include the stdlib venv module

and we install virtualenv through pip

Are we insane? Yes! Does it hurt someone?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle FileNotFoundError when "try .. except IOError ...
FileNotFoundError is a subclass of OSError , catch that or the exception itself: except OSError as e: Operating System exceptions have been ...
Read more >
How to Solve The HTML5 Video 'File Not Found' Error?
This post shares how you can solve the HTML5 video 'File Not Found' error problem and videos playable issue. Read to know ways...
Read more >
[JENKINS-32593] FileNotFoundException in Cucumber Test Result ...
... the plugin throws FileNotFoundException when trying to parse such json report with embedded file. Archiving artifacts [Cucumber Tests] Parsing results.
Read more >
4. Using Python on Windows — Python 3.11.1 documentation
This document aims to give an overview of Windows-specific behaviour you should know ... The embeddable package is a minimal package of Python...
Read more >
How to Setup Your Python Environment for Machine Learning ...
Install the TensorFlow deep learning library (all except Windows) by ... given word embedded models and then to compute the correlation with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found