Difficulties installing Networkx module properly on OSX - python

I want to use networkx (python 2.7.10).
Therefore I have installed networkx with pip. But when I actually tried to import it, I got this error No module named networkx
When I check pip freeze, it return networkx==1.11
Although I tried to reinstall it, it returned
Requirement already satisfied: networkx in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: decorator>=3.4.0 in /usr/local/lib/python2.7/site-packages (from networkx)
I can't figure out what I should do to get it to work.
My Mac version is 10.11.6
It would be greatly appreciated if you could explain the details.

I would really not mess with your systems python.
If you are going to be doing data science work. I would suggest you get a Python distribution like Anaconda and run it inside your home directory so you don't do something you will probably regret.
It has an easy installer. The key during the install to make this problem go away is to say "YES" to changing your path.
After that you will have a nice GUI tool for installing packages.

Related

I am unable to import matplotlib, even after installing the compatible version of it

I have downloaded the matplotlib packages, but every time I run a program, it shows the module is not available. And, when I tried to install the packages again, it is showing that the requirement is already satisfied. What I am doing wrong? please help.

Why can I not run matplotlib on Python 3.10?

My Issue. I am trying to run matplotlib on python 3.10 on my MacOS, but I get the following error:
ModuleNotFoundError: No module named 'matplotlib'
However, when I try running
pip install matplotlib
then I get back
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.9/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.16 in ./mambaforge/lib/python3.9/site-packages (from matplotlib) (1.21.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: pillow>=6.2.0 in ./.local/lib/python3.9/site-packages (from matplotlib) (8.3.2)
Requirement already satisfied: python-dateutil>=2.7 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six in ./mambaforge/lib/python3.9/site-packages (from cycler>=0.10->matplotlib) (1.16.0)
Also, in response to
python3 --version
terminal says
Python 3.9.6
Also, I am able to use matplotlib just fine if I compile my code using Python 2.7.16 on Sublime Text 3.
My Question. How can I get matplotlib to run on Python 3.10?
Since I am still new to Python (or to programming, for that matter), please let me know if I should provide additional information.
Note: I have already looked at this and this, but I couldn't fix the issue.
I have had the same issue. It wasn't only for MatPlotLib, but Pandas and NumPy.
From seeing what the terminal tried to do, it seems that 3rd party libraries are not "compatible" yet. I am using my older version of python now.
When trying to get the libs, it just scrolled through all the versions of matplotlib, and gave errors. It might take some time before this is resolved.
I recently experienced this problem after installing Python 3.10.
Use version Python 3.9. That worked for me, but I can't figure out how to install matplotlib on 3.9 via the command line, but I'm using PyCharm right now, so I got it to work on there.
proof of installation
If you figure out how to install it via the command line, let me know! I'm using two versions of Python. I would like to know how to do it as well. I'm sure I can find it eventually. I believe if you uninstall Python 3.10 and leave only 3.9, it will work.
I found a temporary (unstable) fix for anyone desperate to run matplotlib (and many other packages, e.g. numba, scikit-learn, scipy, etc.) on Python 3.10 for Windows 10, as described by Amit Thinks. Amit uses a source of unstable binaries curated by Christoph Gohlke at UC Irvine, so these are likely not malware infested.
I faced the same issue , while trying to install matplotlib for python 3.10 .
i faced 2 issues
1)It said wheel module not installed (installed via running pip install wheel)
2)It said it required microsoft visual c++ 14.0+ (it was already present when checked in control panel(x64)) (after installing wheel module while running the code[pip install matplotlib] for 3rd time). asked me to download visual studio community 2019 and build tools.... Did so.
And now i was able install matplotlib in python 3.10 and runs fine (when cheking in control panel there was another visual c++ 14.0+ installed (x86) along with (x64),dont know why it works only when x86 version of visual c++ is installed.
if you are using conda enviroment:
conda install -c conda-forge matplotlib
I think it does run on Python 3.10. When you are querying for a graph or plot, try doing this:
import matplotlib.pyplot as plt
I had same issues with matplotlib,pandas,numpay etc on python 3.10 on window 10.
I install with windows binaries packages.
after download "matplotlib‑3.4.3‑cp310‑cp310‑win_amd64.whl"
use this commond:
pip install matplotlib-3.4.3-cp310-cp310-win_amd64.whl

Pip show dependency rationale for package installation during install

When I am trying to install some packages with pip, sometimes some dependency fails to install, and I need to sort out why. A fundamental question is "why did I need to install package X at all?", but I cannot find any way to answer this from the pip install output, even with -vvv. Pip tells me what it is installing, but it doesn't say why it is doing it.
There are various tools to introspect dependency trees of packages, e.g. pipdeptree, especially when they are already installed, but these don't help me when the installation has failed. And it seems that internally pip must already have solved these dependencies and know why it has chosen to install a particular package. So how can I get it to share this information with me at install time?
Edit: It already shows this information when telling you what dependencies are already satisfied, e.g.
Requirement already satisfied: pillow>=6.2.0 in /data2/users/bfarmer/envs/bfarmer_dev_py 39/lib/python3.9/site-packages (from matplotlib>=1.3.1->stf-modelling) (8.0.1)
Requirement already satisfied: certifi>=2020.06.20 in /data2/users/bfarmer/envs/bfarmer_ dev_py39/lib/python3.9/site-packages (from matplotlib>=1.3.1->stf-modelling) (2020.12.5)
(at least I assume that it is what it is telling me at the end of those lines). But when I need this information the most, i.e. when something goes wrong, I get nothing:
Collecting PIL
Downloading http://ehp.bom.gov.au/ehprepo/pypi/simple/pil/PIL-1.1.7.tar.gz (506 kB)
|████████████████████████████████| 506 kB 8.1 MB/s
ERROR: Command errored out with exit status 1:
...
<traceback etc. follows>
In this example I am left wondering why the heck some package wanted PIL when pillow is already there. PIL is basically dead, so I need to update whatever package has a dependency on PIL to use pillow instead. But I have no idea what package that might be, and cannot figure out any way to find out. This seems like basic information, there must surely be a way to get it.
It kind of seems like no, pip cannot do this. I found this issue about it here:
https://github.com/pypa/pip/issues/53
It sounds like they are working on it, but nothing exists currently. I am still interested in workaround/third party solutions though, or advice from other developers about what they typically do in this situation. It kind of seems like I just have to manually trawl through all the dependencies of my dependencies, which just seems stupid. Maybe I can hack something in to the pip source...

Install pyinstaller with no internet access

I'm trying to install pyinstaller on a windows 7 machine with no internet access at all. I've been following the manual as much as I can but I'm totally new to python, pip and whatnot. I downloaded the archive for PyPI and unzipped it to my local drive. After installing PyPiWin32 I CD'd to the pyinstaller folder and ran C:\python27\python setup.py install. It seemed like everything was installing fine but then I got an error that pyinstaller was looking for the "future" package online, and of course couldn't find it...
So then I looked through the manual some more and tried running pip pyinstaller install which now gives me this error
Could not find a version that satisfies the requirement future (from pyinstaller) (from versions: )
No matching distribution found for future (from pyinstaller)
So what I assume went wrong (and I'm really not familiar with this) is that I tried an install, it missed some vital package because that was online, and now it is a bit confused. So is there a way to manually install the "future" package or am I just doing this totally wrong?
Looking at their setup.py file they append a separate future package from PyPI, so you need to install that too before installing PyInstaller on Windows.
When in doubt, you can find a required package using this pattern:
https://pypi.python.org/pypi/<package>
and mostly (if not in all cases) it'll work just fine, therefore if you have a missing package future, just drop it into this url:
https://pypi.python.org/pypi/future
About the future package, it seems they require additional packages on Python 2.6, therefore you'll need importlib and argparse too judging from future's setup.py:
if sys.version_info[:2] == (2, 6):
REQUIRES += ['importlib', 'argparse']
TEST_REQUIRES += ['unittest2']
And just a note for installing, it's easier to navigate into a folder with a setup.py file and do:
pip install .
as it installs like it'd with pip install <package> therefore it'll be easier to uninstall a desired package.
In the end you'd do probably better to go for this question's solutions and download all required packages first with the same environment you want to target. Then you'll just point pip to the right folder, or install manually.

Requirement already satisfied: mysql-python in /usr/local/lib/python2.7/site-packages

I am writing a program that imports MySQLdb in PyCharm, but it reports that "No Module Named MySQLdb".
I googled and tried many solutions within stackoverflow. However, it has not been solved.
When I run the command "pip install MySQL-python", the terminal reports "Requirement already satisfied: MySQL-python in /usr/local/lib/python2.7/site-packages", and MySQL-python indeed exits there.
How could the PyCharm successfully find and import MySQLdb ?
It might be the problem with your PyCharm Interpreter. Go to PyCharm-Preferences-Project Interpreter, choose Python 2.7, which is the version that you installed. Make sure the package that you are looking for is on the list of installed packages below.

Categories

Resources