I'm trying to create a virtual environment, but when I input the mkvirtualenv command this happens
PS C:\Users\jorel\Documents> mkvirtualenv '.\Trading Bot\
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
[--creator {builtin,cpython3-win,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--copies] [--no-download | --download]
[--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: unrecognized arguments: Bot"
SystemExit: 2
I was expecting something like this
(Trading Bot) PS C:\Users\jorel\Documents>
Can you try :
python -m venv venv
source venv/bin/activate
I create my virtual environment like this
Related
I have the following directory:
~/Library/Python/3.9/bin
Inside that folder, for example, appear these two programs:
Executing:
python3 -m submit50
gives...
usage: submit50 [-h] [--logout] [--log-level {debug,info,warning,error}] [-V]
slug
...
However, executing:
python3 -m youtube-dl
gives...
/Library/Developer/CommandLineTools/usr/bin/python3: No module named youtube-dl
What's happening here ?
Why isn't the program youtube-dl being located, and
Why is the path /Library/Developer/CommandLineTools/usr/bin/ appearing there ?
OS: macOS Ventura 13.1
I have a Python script that creates a virtual environment in the following way:
import os
import subprocess
virtualenv_path = os.path.join("/tmp", "my-environment")
subprocess.run(["virtualenv", virtualenv_path], check=True)
This works just fine. However in the Virtualenv documentation I saw that you can "trigger invocation of Python environments from within Python". To do this "you should be using the virtualenv.cli_run method; this takes an args argument where you can pass the options the same way you would from the command line. The run will return a session object containing data about the created virtual environment."
So I ran the following instead:
from virtualenv import cli_run
cli_run(["virtualenv", "/tmp/my-environment"])
However this gives me the following error:
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
[--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
[--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: unrecognized arguments: /tmp/my-environment
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
I am really unsure about why this doesn't work as I am passing the same arguments as I would on the command line.
When you call cli_run as part of virtualenv, you don't need to include the program name, in this case "virtualenv". Simply include your destination, along with any other arguments.
I am using the command in cmd:
py -3.7.6 -m googlesamples.assistant.grpc.audio_helpers
This does not work. I get a response:
Unknown option: -3
usage: C:\Users\Yakuza\AppData\Local\Programs\Python\Python39\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
============================
How to specify version for this to work?
Sorry for the stupid question, I'm just tired, but I want to finish
You cannot specify 3.7.6 using the Python Launcher for Windows it only recognizes the first two digits, major.minor. You could use a shebang line in the file with the full path. Or specify the path to the version you want - C:\path\to\pythonV3.7.6\python.exe -m ...
I am trying to run my python script without writing python func.py.
I've added to my script file #!/usr/bin/python2.7
did chmod +x func.py
when I try to run: ./func.py -p show -c all
the script works fine but if I try to take off the "flags" (-p , -c) or the "./" or ".py" it won't work.
taking flags off returns:
[root#pg66 tmp]# ./func.py show all
usage: func.py [-h] [-p PROCESS] [-c CLUSTER] [-t TYPE]
func.py: error: unrecognized arguments: show all
taking "./" & ".py" off returns:
[root#pg66 tmp]# func.py -p show -c all
-bash: func.py: command not found
edit: i have 3 flags -p -c -t , dont know where the -h came from. -t can be null so when i write -p show -c all it works.
you can simply use the chmod +* x in the location with the python file. This makes it easier for linux/unix After that you can run it by ./main.py Assuming the file is named as main.py. You can also remove the .py extension then give the permission by chmod +* x and after that then just execute by ./main. Another way to do this is simply going to the execution script of your terminal then add an alias for directly running the script just by typing the alias name
My system is 5.0.9-2-MANJARO
I've already set the python scripts workaround described in archwiki
➜ ~ cat /home/nfl/bin/python
#!/bin/bash
script=$(readlink -f -- "$1")
case "$script" in (/opt/cocos2d-x/*)
exec python2 "$#"
;;
esac
exec python3 "$#"
➜ ~ which python
/home/nfl/bin/python
➜ ~ echo $PATH
/home/nfl/.nvm/versions/node/v10.15.3/bin:/home/nfl/bin:/usr/local/bin:/opt/cocos2d-x/tools/cocos2d-console/bin:/opt/cocos2d-x/tools/cocos2d-console/plugins/plugin_package:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
➜ ~
When I run python script that output current python version, it output python2 in directory specified in the script(/opt/cocos2d-x/*) and python3 in non specified dir. So everything work fine now.
The problem is when I try to run sdkbox(cocos2d plugin) with PATH, it seem like python3 is used instead of python2.
➜ ~ which sdkbox
/opt/cocos2d-x/tools/cocos2d-console/plugins/plugin_package/sdkbox
➜ ~ sdkbox
RuntimeError: Bad magic number in .pyc file
➜ ~
But when I run it directly from the directory, it works
➜ plugin_package pwd
/opt/cocos2d-x/tools/cocos2d-console/plugins/plugin_package
➜ plugin_package ./sdkbox
_______ ______ _ _ ______ _____ _ _
|______ | \ |____/ |_____] | | \___/
______| |_____/ | \_ |_____] |_____| _/ \_
Copyright (c) 2016-2018 SDKBOX Inc. v1.0.2.8
usage: sdkbox [-h] [-v] [-p [PROJECT]] [-b [PLUGIN]] [-D SYMBOL] [-i INPUT]
[-o OUTPUT] [-q] [-d [DAYS]] [-l LEGACY] [--key KEY] [--dryrun]
[--forcedownload] [--noupdate] [--alwaysupdate] [--patcherrors]
[--nopatching] [--nopatchingcpp] [--jsonapi] [--forcecopy]
[--mkey MKEY] [--mvalue MVALUE] [--local] [--remote]
[--info INFO] [--runin RUNIN] [--apitoken APITOKEN]
[--silenttime SILENTTIME] [--projectpath PROJECTPATH]
[--platform PLATFORM]
{import,info,update,forget,restore,list,clean,symbols,version,set,tracking,encrypt,decrypt}
sdkbox: error: too few arguments
➜ plugin_package
What happen exactly and how to fix this?
Shebang might be your solution. It addresses the python interpreter by the shebang.
Should I put #! (shebang) in Python scripts, and what form should it take?
I would suggest using virtual environment for this purposes.
virtualenv