简体   繁体   中英

Run Python script using virtualenv

I have a python script named utils (note without any.py extension). Where I have some utility functions. The path is also added in PATH variable.

#!/usr/bin/env python3

import click, sys

@main.command('echo', context_settings=dict(help_option_names=['-h', '--help']))
def echo_test():
    click.echo("Hello World")
    sys.exit(0)

It works fine. Now I can run from anywhere utils echo .

I am trying to make the script to use virtualenv instead of the global python. I have tried

#!/path/to/venv/bin python3

import click, sys

Then it throws me error permission denied

Permissions for utils file are -rwxr-xr-x

Any idea how could I use venv with script.

Try changing the file permissions via this command:

chmod 755

chmod -R 755 on the /usr/lib/python/site-packages/virtualenv

or even

chmod +x

Suggest you read the man page for chmod by using this command

man chmod 

if you are not sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM