Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 10125  / 3 Years ago, sat, august 21, 2021, 8:36:31

Hi I upgraded my Ubuntu to 16.04 but whenever I try to run a Python program or pip install (both Python 2.7 or Python 3.5) I get the following error:



ImportError: No module named 'encodings'


Screenshot


More From » upgrade

 Answers
3

From the comments, it looks like you were trying to use pip3 inside a virtualenv that is set up for Python 2. Note that running virtualenv venv creates a virtualenv named venv for Python 2 by default on Ubuntu if you don't specify the Python version explicitly.



In any case, if you want to create a virtualenv for Python 2, run:



virtualenv venv  # create virtualenv named venv for Python 2


If you want to create a virtualenv for Python 3, run:



virtualenv venv -p python3  # create virtualenv named venv for Python 3


In both cases, after you have activated the virtualenv by running source venv/bin/activate, you just need to call pip to install Python packages; this still applies for a virtualenv created for Python 3 because pip already knows what Python version you are using, so don't call pip3.


[#14498] Saturday, August 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
serveeel

Total Points: 347
Total Questions: 106
Total Answers: 117

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
;