Sunday 14 February 2016

Python and pyplot

Importance of virtual environment

I am trying to compile the code from cs231n, but it says numpy.core.multiarray failed to import. It is suggested on the web to update the python numpy by pip install -U numpy. However, I did not update it in the virtual environment, instead, I updated in the global space. Then when I tried to compile my ros catkin code, it seems the header file generated from msg using python no longer works.

To resolve this, I have to re-init a catkin workspace, and copy the original src folder to replace the new src folder. Also note to source ./devel/setup.bash. In conclusion, any update and change should be made in the virtual environment only.

Anyway, later I found that matplotlib.pyplot could not be used in the cs231n virtual environment, though matplotlib can be imported. Outside the virtual environment, however, matplotlib.pyplot can be used with no problem. Just note that when using import matplotlib.pyplot as plt, plt.show() need to be called at the end to visualize the result as stated here.  

No comments:

Post a Comment