title: Installing PyYAML in docker container
body: <p>I am trying to build a container with the yaml package in it.
  However when I try to import the package I have the following error:</p>
  <pre><code>&gt;&gt;&gt; import yaml
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  ModuleNotFoundError: No module named 'yaml'
  </code></pre>
  <p>When I (re)build the Dockerfile I have the following message:</p>
  <pre><code>Step 14/25 : RUN pip install PyYAML==5.4.1
   ---&gt; Running in 1e94e1d4e7e5
  Requirement already satisfied: PyYAML==5.4.1 in /root/.local/lib/python3.9/site-packages (5.4.1)
  </code></pre>
  <p>For me it means that it's correctly installed.</p>
  <p>However, when I do a <em>pip freeze</em>, PyYaml is not there.
  I also tried to simply reinstall it in the container:</p>
  <pre><code>pip install PyYaml
  WARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
  Defaulting to user installation because normal site-packages is not writeable
  Collecting PyYaml
    Downloading PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl (630 kB)
       |████████████████████████████████| 630 kB 7.5 MB/s 
  Installing collected packages: PyYaml
  ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/.local'
  Check the permissions.
  </code></pre>
  <p>Here are the permissions:</p>
  <pre><code>ls -la
  drwxr-xr-x 16 1270 1007 4096 Apr 13 20:16 .
  drwxr-xr-x  5 1270 1007 4096 Apr 14 16:09 ..
  
  </code></pre>
  <p>I also tried the following solution : <a href="https://github.com/yaml/pyyaml/issues/291#issuecomment-580608091" rel="nofollow noreferrer">https://github.com/yaml/pyyaml/issues/291#issuecomment-580608091</a>
  by adding the following commands:</p>
  <pre><code>#In the dockerfile :
  ENV PYTHONPATH=&quot;/root/.local/lib/python3.9/site-packages (5.4.1)&quot;
  
  #or
  #In the container
  export PYTHONPATH=$PYTHONPATH:/root/.local/lib/python3.9/site-packages (5.4.1)
  </code></pre>
  <p>But I've still the same error.</p>
  <p>This is my Dockerfile:</p>
  <pre><code>FROM python:3
  
  RUN apt-get update
  RUN apt-get install ffmpeg libsm6 libxext6 -y
  RUN pip install pip --upgrade pip
  RUN pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
  RUN pip install imageio
  RUN pip install matplotlib
  RUN pip install numpy
  RUN pip install opencv-python
  RUN pip install pandas
  RUN pip install Pillow
  RUN pip install scipy
  RUN pip install wandb --user
  RUN pip install PyYAML==5.4.1 
  RUN pip install addict
  RUN pip install future
  RUN pip install lmdb
  RUN pip install requests
  RUN pip install scikit-image
  RUN pip install tb-nightly
  RUN pip install tqdm
  RUN pip install yapf
  
  ENV PYTHONPATH=&quot;/home/GAN&quot;
  ENV PYTHONPATH=&quot;/root/.local/lib/python3.9/site-packages (5.4.1)&quot;
  
  WORKDIR /home/
  CMD /bin/bash
  </code></pre>
  <p>I also tried to use a virtual environment but I get permission errors with wandb.</p>