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.

Fail to use flake8 with pdm run

See original GitHub issue

Hi, I am trying to test the usage of PDM for some projects, I made an example one. It works perfectly with pip and also with pipenv, everything was painless with PDM too until I try to run the flake8 linter.

If I run directly flake8 myfile.py it cannot find the flake8 command, that’s ok, I got the same error with pipenv, but with pipenv I was able to run it with pipenv run flake8 myfile.py, so I tried in the same way with PDM, using pdm run, but I got the error that cannot find flake8

root@ba68f6e2b3e6:/src# pdm run -v flake8 
Traceback (most recent call last):
  File "/usr/local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 233, in main
    return Core().main(args)
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 168, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 163, in main
    f(options.project, options)
  File "/usr/local/lib/python3.9/site-packages/pdm/cli/commands/run.py", line 281, in handle
    sys.exit(runner.run(options.command, options.args))
  File "/usr/local/lib/python3.9/site-packages/pdm/cli/commands/run.py", line 219, in run
    return self._run_process(
  File "/usr/local/lib/python3.9/site-packages/pdm/cli/commands/run.py", line 154, in _run_process
    process = subprocess.Popen(expanded_args, cwd=cwd, env=process_env, shell=shell)
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/src/__pypackages__/3.9/bin/flake8'
root@ba68f6e2b3e6:/src# pdm run __pypackages__/3.9/bin/flake8 
[FileNotFoundError]: [Errno 2] No such file or directory: '__pypackages__/3.9/bin/flake8'

The file is correctly there placed, but pdm cannot find it.

What I am doing wrong?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
pawamoycommented, Mar 24, 2022

If you’re working on Windows and copied __pypackages__ into the image, then yes, it would never have worked. Try to only copy the relevant files into your image, not the whole repository. There’s an example here: https://pdm.fming.dev/usage/advanced/#use-pdm-in-a-multi-stage-dockerfile

I believe this can be closed, thank you for reporting back @SirMartin 🙂

0reactions
SirMartincommented, Mar 24, 2022

Hi, thanks for the answer.

I found the reason for my errors. The problem it seem because I made the pdm install locally and later ran the docker, because of that the __pypackages__ folder was copied to the container and failed when I run it.

Have this sense? I understand that has no meaning and it was my mistake.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running in docker+pytest+flake8 fails · Issue #1555 - GitHub
Expected result. When I add the following lines to my dockerfile just before the "cmd pdm run pytest test". # Try to fix ......
Read more >
Advanced Usage - PDM
Advanced Usage#. Automatic Testing#. Use Tox as the runner#. Tox is a great tool for testing against multiple Python versions or dependency sets....
Read more >
Linting With Flake8 - PyBites
Linting is the process of running a program that analyses code for programmatic errors such as bugs, actual errors, styling issues etc. Put...
Read more >
Working on a project - Copier PDM - pawamoy's website
To run a task, use pdm run duty TASK [ARG=VALUE...] . ... The code quality analysis is done with Flake8, and a battery...
Read more >
Invoking Flake8 — flake8 6.0.0 documentation
Once you have installed Flake8, you can begin using it. Most of the time, ... It will only install it for the version...
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