Issue
I've installed matplotlib and set the default python version as 3.9.2. I currently have matplotlib v3.3.4 installed. I'm using VScode in Linux.
I've tried using sudo apt-get install python3-matplotlib but that only returns "python3-matplotlib is already the newest version(3.3.4-1)." I can't seem to get conda or pip to work (I don't know if I need to install other packages); the terminal returns "bash: conda: command not found" and "no module named 'pip'". Any advice on where to go from here would be greatly appreciated!
Solution
The specific content of these commands may vary slightly depending on the specific Linux distribution and package management system you are working with.
However, you need to follow the same general steps.
- Open a sudo command prompt for the following instructions by pasting this command into a terminal.
su -l
Then, enter your sudo credentials when promted.
- Install conda (miniconda in this example) by copying and pasting these commands into your terminal. Installation instructions from here: https://docs.conda.io/projects/miniconda/en/latest/
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
Restart your terminal and run as sudo using the command in step 1.
Activate Conda by running this command in your terminal (for bash).
~/miniconda3/bin/conda init bash
- Verify you can access conda using the following command. You should get the help page. Also, you should see "(base)" to the far left of your terminal prompt.
conda
- Create a new environment with python 3.9.2 using a name of your choosing. In this example, the environment name is "TestEnv". Pick whatever name you like.
conda create -n TestEnv python=3.9.2
- Activate the new environment.
conda activate TestEnv
- Install matplotlib version 3.4.3
conda install matplotlib==3.4.3
- Verify successful installation.
conda list
- Finally, you will need to set this environment to be used with VSCode. Here is some guidance on that process: https://code.visualstudio.com/docs/python/environments
I tested and reproduced this example in ubuntu 18.04.
Answered By - Travis.M
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.