Anaconda和Pycharm中tensorflow环境无法导入opencv的问题
将D:/Anaconda/Lib/site-packages路径中的安装包复制到D:/Anaconda/envs/tensorflow/Lib/site-packages就能解决导入cv2的问题
jupyter检验一下
PyCharm中配置tensorflow后无法导入Opencv
点击show all添加tensorflow下的python.exe
点击+,选择Existing environment
验证一下
import tensorflow as tf
import cv2
img = cv2.imread("1.jpg")
cv2.imshow("image", img)
cv2.waitKey(0)
data1 = tf.constant(2, dtype=tf.int32)
data2 = tf.Variable(10, name='var')
print(data1)
print(data2)
sess = tf.Session()
print(sess.run(data1))
init = tf.global_variables_initializer()
sess.run(init)
print(sess.run(data2))
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
y = np.array([3, 5, 7, 6, 2, 6, 10, 15])
plt.plot(x, y, 'r')
plt.plot(x, y, 'g')
x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
plt.bar(x, y, 0.5, alpha=1, color='b')
plt.show()
参考博客
https://blog.****.net/red_ear/article/details/80083408
https://blog.****.net/red_ear/article/details/80083408