Reputation:
I'm trying to reforce the installation of the package inside of my code. For that I've this:
import sys
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", 'JPype1==0.6.1 --force-reinstal'])
subprocess.check_call([sys.executable, "-m", "pip", "install", 'mysqlclient pymysql'])
However, I am getting the following error:
ERROR: Invalid requirement: 'JPype1==0.6.3 --force-reinstal'
subprocess.CalledProcessError: Command '[python.exe', '-m', 'pip', 'install', 'JPype1==0.6.3 --force-reinstal']' returned non-zero exit status 1.
Anyone have a solution? Thanks!
Upvotes: 1
Views: 303
Reputation: 71
The issue is subprocessing requires a separate argument for each argument being sent to the command. Also, 'reinstall' is spelt wrong. The correct code is as follows, where each argument is separate and the typo is fixed:
import sys
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", 'JPype1==0.6.1', '--force-reinstall'])
subprocess.check_call([sys.executable, "-m", "pip", "install", 'mysqlclient', 'pymysql'])
Upvotes: 1