不使用pip install命令安装Python应用程序依赖项

时间:2017-09-09 13:31:19

标签: python opencv

我正在尝试从C#程序运行Python脚本。我使用Microsoft的官方文档:Inter-process communication between C# and Python.我应该将此项目部署为.exe。当我正在感谢.exe文件时,它会在下面给出error: 'No module named numpy/ matplotlib.Suggest me some idea to resolve this issue.样本文件:

demo.py

import numpy as np
from skimage import measure
import scipy
import cv2

'some code using above package'

1 个答案:

答案 0 :(得分:2)

您可以在本地安装没有root / admin权限的python包。我测试了下一个代码并且它有效。

import pip
import os
import sys 

def pip_install(packages, dir_to_install):
    for package in packages:
        pip.main(['install', '--target={}'.format(dir_to_install), package])

local_repo_path = os.path.abspath('local_repo')
sys.path.append(local_repo_path)
packages_list = ['numpy', 'scikit-image', 'opencv-python']
pip_install(packages_list, local_repo_path)

import numpy as np
from skimage import measure
import scipy

'some code using above package'