1

100% noob here. Second day using Linux.
Using Ubuntu 16.04. When executing

sudo pip install numexpr

I got the message as follows:

The directory '/home/ark/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ark/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: numexpr in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: numpy>=1.6 in /usr/lib/python2.7/dist-packages (from numexpr)

It appears to me though the package is not correctly installed.

Thomas
  • 6,223
Ark
  • 21
  • check the ownership of /home/ark/.cache and /home/ark/.cache.pip it should belong to you. – George Udosen Jan 14 '17 at 15:06
  • Try to install that package as root, as the $HOME environment variable is set to /home/ark instead of /root using sudo. sudo su -; pip install numexpr. – Thomas Jan 14 '17 at 15:16

1 Answers1

1

With Python, it's generally recommended to install your dependencies in a virtual environment. In that way, you don't pollute the system's Python libraries with your own. Furthermore, it allows you to install different versions of the same package in separate virtual environments, which might be useful if you are working on multiple projects.

With Python 3 on Ubuntu, you first have to install python3-venv to be able to create virtual environments. Here are all commands you have to run:

$ sudo apt-get install python3-venv
$ pyvenv env
$ source env/bin/activate
$ pip install numexpr
$ python  # The library is now available and you may import it

If you are using Python 2, you will have to install the 3rd party tool virtualenv instead to create and use the virtual environment, since it doesn't come with one built-in. Note though that its commands are a bit different.