Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have PermissionError when I run "poetry run" command

Environment

  • Ubuntu 20.04
  • Python 3.7.3
  • Poetry 1.0.8

My Problem

I installed poetry to manage packages, and I tried it with following simple project,

.
└── myproject
    ├── README.rst
    ├── myproject
    │   ├── __init__.py
    │   ├── main.py
    ├── myproject.egg-info
    │   ├── PKG-INFO
    │   ├── SOURCES.txt
    │   ├── dependency_links.txt
    │   ├── requires.txt
    │   └── top_level.txt
    ├── poetry.lock
    ├── pyproject.toml
    └── tests
        ├── __init__.py
        └── test_myproject.py

To run main.py I tried

$ poetry run myproject/main.py

But I had an error, which says,

[PermissionError]
[Errno 13] Permission denied

What I tried

To run my code, I tried another way.

$ poetry shell
(myproject-x8XipcUE-py3.7)$ python myproject/main.py

I had no error...

What is the problem for my poetry run command?

like image 947
Y. P Avatar asked Jun 07 '20 05:06

Y. P


Video Answer


2 Answers

Just for reference you can also do poetry run python myproject/main.py.

like image 167
DaveR Avatar answered Nov 28 '22 00:11

DaveR


My guess is that myproject/main.py isn't an executable (doesn't have the 'x') permission. That's why you can run it with python myproject/main.py, but can't run it as the main exe. To fix it, run chmod +x myproject/main.py, and then try poetry run again.

Of course, you'll have to have a proper Shebang at the very top of main.py. Something like #!/usr/bin/env python (again - at the very beginning of the file).

like image 31
Roy2012 Avatar answered Nov 27 '22 23:11

Roy2012