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.

2
  • check the ownership of /home/ark/.cache and /home/ark/.cache.pip it should belong to you. Jan 14, 2017 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, 2017 at 15:16

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .