4

Question

I am not sure why when virtualenv active, pip freeze stills showing all modules when it suppose NOT to. What am I doing wrong?

On the terminal

I tried two ways to create a virtual env:

virtualenv my-virtualenv

virtualenv --no-site-packages my-virtualenv

then activate it

source my-virtualenv/bin/activate

Results

Both show all packages (when they suppose not to). Running command pip freeze I get:

(my-virtualenv)$ pip freeze

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
actionlib==1.11.9
angles==1.9.11
bondpy==1.7.19
camera-calibration==1.12.20
camera-calibration-parsers==1.11.12
catkin==0.7.6
cv-bridge==1.12.4
diagnostic-analysis==1.9.2
diagnostic-common-diagnostics==1.9.2
diagnostic-updater==1.9.2
dynamic-reconfigure==1.5.48
gazebo-plugins==2.5.13
gazebo-ros==2.5.13
...
rosnode==1.12.7
rosparam==1.12.7
rospy==1.12.7
rosservice==1.12.7
rostest==1.12.7
rostopic==1.12.7
rosunit==1.13.5
roswtf==1.12.7
tf2-ros==0.5.16
topic-tools==1.12.7
xacro==1.11.2

Running

(my-virtualenv)$ which python
/home/user/.../my-virtualenv/bin/python

(my-virtualenv)$ python -V
Python 2.7.12

and

(my-virtualenv)$ which python3
/usr/bin/python3

(my-virtualenv)$ python3 -V
Python 3.5.2

Hence, I even can use python3 when virtualenv is activated but it uses the pc installed module. Moreover, new installed packages are install in the pc and not the virtualenv and I can't install python3 in the vitualenv because it "exists" already (but in the pc).

Community
  • 1
  • 1
Griselle Z
  • 127
  • 1
  • 9

1 Answers1

0

I was having the same issue and it was because, somehow, Python configuration of ROS was generating it.

I solved it removing the source commands of ROS from the ~/.bashrc. E.g.:

source /opt/ros/melodic/setup.bash
source $HOME/ROS/aslam_ws/devel/setup.bash

By the way, I realised that, before changing anything, creating the environment from PyCharm works properly too (when in the terminal I still had the issue).

There must be a better solution but I haven't found it yet.