Plotting a graph using matplotlib [duplicate] - python

This question already has answers here:
Problem Importing Pylab in Python 2.6
(2 answers)
Closed 7 years ago.
I have been trying to plot simple graphs in python 2.7 using matplotlib. I am using ubuntu and I have installed all the dependencies and matplotlib. Still when I try to run the code for plotting graphs, it gives me an error in terminal saying
I am new to python. What does this mean? and how do I resolve this?

I also use Ubuntu 14.04. It seems that the dependency has been messed up. The most easiest way is to install Anaconda as it handles all these sorts of issues quite well and very easy to install.
Here is the link for download Anaconda.
http://continuum.io/downloads
You could choose either python 2.7 or 3.4. (I personally prefer 3.4)
Just download that installer. I assume it's in /home/your_user_name/Downloads folder. Just open an terminal, type
$cd /home/your_user_name/Downloads
$ls
make sure you see your downloaded installer in this folder. Then
bash Anaconda-2.2.0-Linux-x86_64.sh
this could be different if you are using 32-bit Ubuntu OS.
After the installation, it asks you whether add the PATH to environment. Choose yes. Finally, open a terminal again
$conda update conda
$conda update anaconda
Now you are ready to go.

Related

How to instal python basemap on MacOS?

For the past 5 hours, I have been trying to install basemap module on my laptop. I have tried various methods and apparently they do not work. Firstly I have tried the one that was posted on stackoverflow 5 years ago using brew, but when you download zip file, it does not contain installer(that what terminal says). I was trying to install it directly from the terminal, also did not work. Official documentation on the installation of the package (https://matplotlib.org/basemap/users/installing.html) is complicated and I could not understand the steps. Can someone please tell me how to install it on MacOS?
P.S. I am working in the jupyter and currently trying to install the package using Anaconda

Packages installed via Pip do not get imported in Python VSCode [Windows 10]

Trying to install new packages via pip on Windows, but after it installs - Python cannot resolve the import. For Example, I have just installed the Python package similaritymeasures and pip correctly installed it, but when I import it into my Python program, it cannot find the import. Has anyone know a way around this?
Make sure that you restart VSCode after downloading your package. Sometimes, when you download a package while VSCode is still running, it doesn't recognize the package when using import similaritymeasures.
If that didn't work, then make sure that VSCode is using your preferred version of python. It is possible that you have more than one python version and it's using a non-compatible one to run your code. This can be done at the bottom right corner of the window by clicking the box that says: (for example) 3.9.5 64-bit. Then select a different (preferably older) version from the pop up widnow.
These are the solutions that came to my mind, I hope this helped.

How to create virtual environments with different Python versions [duplicate]

This question already has answers here:
Use different Python version with virtualenv
(41 answers)
Closed 1 year ago.
I am very new to Python. I am trying to install a library called Mesa (https://mesa.readthedocs.io/en/master/index.html) in a virtual environment, but each time I try to clone the repository I get the error message: An error occurred while installing pandas==1.2.4
I believe the problem is that I have installed Python 3.9, but Mesa works with Python 3.7. I have installed Python 3.7 on my computer also, but do not know how to make a virtual environment which runs Python 3.7.
I have virtualenv installed but this is as far as I have gotten... very specific answers would be much appreciated as I still don't really know what I am doing!
From my experience the easiest way is using Anaconda and creating environments with specific versions inside it. https://www.anaconda.com/
The second way I use is google colab its really fast if I just want to check something on different version and requires no setup just lunch it from your google account
With python3.8:- virtualenv -p python3.8 env_name
replace python version like python3.9, python3.7..

Installed Python 3.8.5, but my terminal still detects Python 2.7 (Catalina on mac) [duplicate]

This question already has answers here:
Dealing with multiple Python versions and PIP?
(28 answers)
Closed 2 years ago.
I was trying to install biopython with pip, but I get an error saying Python 3.6 or later is required, but 2.7 was detected. Weirdly though, when I look for my python version, it indicates I have 3.8.5 installed.
Should I move directories somehow? I just upgraded my Catalina version and did a thorough cleanup on my mac. Maybe I accidentally moved a file or two?
here's what my terminal looks like
Thank you!!!!!
You have to deconflict pip and make sure you're using the right one. There's a good answer on another Stack Overflow question.
The bottom line is, you might try:
which -a pip
to see all pip installations in your path.
You can use a specific version of pip like this:
python3 -m pip install something
or, I think you can also do:
pip3.6 install something

Install Python packages and directories (windows) [duplicate]

This question already has answers here:
How to change the path of Python in Spyder?
(5 answers)
Closed 4 years ago.
I am new to configuring and setting up Python from scratch.
I have installed Anaconda and I plan to use Spyder for python development. I also have a older version of Python installed on the same machine elsewhere.
I needed to get my hands on a package to use in Spyder which I needed to download and install.
I downloaded and installed pip directly from the website and then I used this in the command line of the older python install to obtain the package I required.
However I don't understand how I go about making this available to Spyder. I believe it works on a folder structure within it's own directory and I am unsure how to change this to get the package I have already downloaded.
I thought I might be able to copy it across, or point it at the directory where the package was downloaded to but I cannot work out how to do this.
I also tried using pip from within Spyder to work but it cannot find it.
Can you please let me know what I need to check?
from the command line can you use pip? Btw I believe python 3 comes with pip included anyway you need to make sure it's in your path
Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
Try to:
Open Anaconda Prompt and then do: pip install whatever - to install wheels
If you want to install spyder the open Anaconda Navigator - and you should be in the home tab - then highlat spyder and press install - thats all.
There are other ways but within spyder ipython console you can install package like.
In [1]: import pip
In [2]: pip.main(['install', 'module-name'])

Categories

Resources