Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't create virtualenv on Ubuntu 18.04 with Python 3.8

I have a Docker file with the following:

FROM ubuntu:18.04
RUN apt-get update --fix-missing
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get install -y build-essential
RUN apt-get install -y python3.8
RUN apt-get install -y python3-pip python3.8-venv python3.8-dev
ENV VIRTUAL_ENV=/run/env
RUN python3.8 -m venv $VIRTUAL_ENV

I get this error when building it:

Step 8/8 : RUN python3.8 -m venv $VIRTUAL_ENV
---> Running in d05326069de2
Error: Command '['/run/env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' 
returned non-zero exit status 2.

When I try to add this line before it:

RUN python3.8 -m ensurepip --upgrade

I get the error:

File "/usr/lib/python3.8/distutils/sysconfig.py", line 466, in _init_posix
ModuleNotFoundError: No module named '_sysconfigdata__x86_64-linux-gnu'

How do I fix this?

like image 990
skunkwerk Avatar asked Dec 21 '19 20:12

skunkwerk


3 Answers

As workaround

sudo ln -s   /usr/lib/python3.8/_sysconfigdata__linux_x86_64-linux-gnu.py  /usr/lib/python3.8/_sysconfigdata__x86_64-linux-gnu.py

But i hope it will be fixed soon in Ubuntu.

like image 70
slav0nic Avatar answered Oct 20 '22 06:10

slav0nic


oops, this was a mistake in the packaging -- I've gone ahead and fixed it here

there was a subtle conflict between the system python3-distuils (provided by debian) and the python3.x-venv module (provided by the ppa)


disclaimer: I'm the maintainer of deadsnakes

like image 28
Anthony Sottile Avatar answered Oct 20 '22 07:10

Anthony Sottile


For me, I could fix my Python 3.8 installation and the problem with this:

sudo apt --fix-broken install
like image 4
CGFoX Avatar answered Oct 20 '22 08:10

CGFoX