The first direction in my book starts with:
import matplotlib.pyplot as plt import numpy as np import pandas as pd import sklearn.linear_model
Simple enough but I have spent two days and many hours trying & failing to get these to import to no avail such that I greatly appreciate any help. I've even created a new account to try the whole process again in a clean fashion.
when I look to import matplotlib, I have no issue if I use the default Python 2.7 as already installed on my machine. However, if I use the more recent version of Python 3.6 (without which I can't import sklearn) then I return an error AttributeError: 'version_info' object has no attribute 'version'. I've tried solutions as here (AttributeError: module 'matplotlib' has no attribute 'plot'), (Can't "import matplotlib.pyplot as plt"), and here (Can't import pyplot in python 3.8) to no avail. Many of the solutions appear to revolve around using pip, installing packages like pillow (I already have this). After multiple reinstalls I'm now running pip 21.3.1. Interestingly, I've installed matplotlib-3.3.4 which appears the most recent. It's when using python3 that I get this error. If I work under python2.7, I can import matplotlib but then matplotlib.version returns 1.3.1
I can now import numpy after uninstalling and reinstalling everything
On pandas I get the same " AttributeError: 'version_info' object has no attribute 'version' ". As with point 1, most solutions here appear to revolve around uninstalling pip/pandas, which I've already done, but am getting the same error
I can import sklearn
Again, I've really hit a brick wall here and have spent many hours going through old posts such that I greatly appreciate any and all help.
CodePudding user response:
you might like Anaconda - it manages this kind of thing in the background. https://www.anaconda.com/products/individual
CodePudding user response:
Hey try using environment pyenv is a good one for macbook or if you want you can use conda or you can use virtual environment which can be directly installed using a simple pip command.
This will allow you with the python version control 2x.x or 3.x.x. and also you can setup environment for other projects independently and does not affect the system environment.
CodePudding user response:
Wanted to come back with the answer here in case others are struggling similarly. Ultimately, both Arunbh and Lynne had the right idea that the error related to something in the initial install and the associated path management. I ended up drwawing in a friend to help me and he installed the homebrew package management system along with pyenv. After then reinstalling all the salient packages it started to work as desired.
