Python: How to find version number for mpl_toolkits? - python

I understand how to find the version number of a python package normally. I would usually just import it in python and do <package name>.__version__, or run pip freeze and locate the package of interest.
However, this doesn't work with mpl_toolkits. If I do
import mpl_toolkits
mpl_toolkits.__version__
I get an attribute error. Running pip freeze, the package doesn't appear. Since the import works it must be installed though. I feel like I'm missing something obvious but can't work out what's going on here, so sorry if the question is dumb.

Related

from setuptools.errors import OptionError ImportError: cannot import name 'OptionError' from 'setuptools.errors'

i am trying to create an executable using cx_freeze. and when i run
python setup.py build i get the following error:
from setuptools.errors import OptionError
ImportError: cannot import name 'OptionError' from 'setuptools.errors'
I am working in anaconda. I tried reverting to a previous cx_freeze version with no luck.
This a a new problem two month ago when i created another virtual envieonment i didn't have this problem. This is why i'm guessing it could be maybe a version issue. However i can't seem to find the correct version to install.
i also checked other related issues however i didn't find a solution that works for me. If you have an idea please let me know!
Thank you
It's difficult to tell without additional info, package versions, a more complete trace, etc.
I ran into this same error during a build post-upgrade of cx_Freeze but after already having setuptools installed. Reinstalling setuptools to the most current version (65.6.3) corrected the error in my case. I'm running cx_Freeze version 6.13.1 if it helps move you past the error.
Typically, Python errors of the sort ImportError: cannot import name ... indicate circular dependencies, e.g.,: https://stackoverflow.com/a/9252628/9975319 - it could be that the order of imports cx_Freeze does changes across builds causing the dependencies to import incorrectly but I haven't dug deeper into it.

Setting up a second IDE (Atom) after already installing Anaconda - how to use my python packages in Atom?

Sorry for the basic question but have got myself into a tangle trying to fix this and not too sure how to resolve it. Essentially, I've put a fresh install of pop_os on my computer (new to linux, which doesnt help) and then installed Anaconda - all good so far. However, I've decided that I would like to start using Atom as an IDE. I've installed atom, all good, set it up so that I can run python scripts from there, also all good - however, as soon as I try to import a package, say numpy or pandas etc., it gives me the 'no module found' error. Then if I head over to the terminal and pip install it I get 'requirement already satisfied: numpy in ./anaconda/lib/python3.9/site-packages(1.20.3)'.
I'm guessing the issue is that Atom isn't looking for packages in the right place - any ideas how to fix? Go gentle on me folks!

Trying to import GitHub module

I'm trying to import https://github.com/chrisconlan/algorithmic-trading-with-python in my code. I've never imported anything from GitHub before and have looked at various other questions that have been asked on Stack Overflow regarding this problem but it just doesn't work. When I try to run the 'portfolio.py' code for example I keep getting a ModuleNotFound error for 'pypm'. What exactly is the correct way to import such a module or the whole GitHub directory?
I'm working with Visual Studio Code on Windows.
You will need to pip install the module. In your case the command you would need to run is python -m pip install -U git+https://github.com/chrisconlan/algorithmic-trading-with-python. Once you have done that you need to find the name of the module. You can do this with pip list. Find the name of the module you just installed.
Then you just stick import <module name> at the top of your code with the rest of your imports.
What i used to do in this is to clone the repository on the folder where are installed the python's packages. This is useful when you do not want to use the pip cmd tool, keeping the pip's cache memory under control.

Unable to import 'numpy'pylint(import-error)

I was following the tutorial of programming the Monty hall problem in python and all these errors came up and I've looked through the tutorial multiple times and still don't know what I've done wrong.
This is where all these errors came up in the same order
Unable to import 'numpy'pylint(import-error) Unable to import 'matplotlib.pyplot'pylint(import-error) Unused variable 'Simulate'pylint(unused-variable)][1]
Here is where these errors came up in the same order
Unused variable 'TakeTurn'pylint(unused-variable) Unused variable 'DisplayResults'pylint(unused-variable)][2]
And finally this error Instance of 'Simulation' has no 'Simulate']3
Be sure to install those packages with pip before importing them. If not installed python would look for the package a not find it. Then you get errors.
Check if those packages are installed on your machine.
Like pip install matplotlib

How to import a module from PyPI when I have another module with the same name

I'm trying to use the lockfile module from PyPI. I do my development within Spyder. After installing the module from PyPI, I can't import it by doing import lockfile. I end up importing anaconda/lib/python2.7/site-packages/spyderlib/utils/external/lockfile.py instead. Spyder seems to want to have the spyderlib/utils/external directory at the beginning of sys.path, or at least none of the polite ways I can find to add my other paths get me in front of spyderlib/utils/external.
I'm using python2.7 but with from __future__ import absolute_import.
Here's what I've already tried:
Writing code that modifies sys.path before running import lockfile. This works, but it can't be the correct way of doing things.
Circumventing the normal mechanics of importing in Python using the imp module (I haven't gotten this to work yet, but I'm guessing it could be made to work)
Installing the package with something like pip install --install-option="--prefix=modules_with_name_collisions" package_name. I haven't gotten this to work yet either, but I'm guess it could be made to work. It looks like this option is intended to create an entirely separate lib tree, which is more than I need. Source
Using pip install --target=lockfile_from_pip. The files show up in the directory where I tell them to go, but import doesn't find them. And in fact pip uninstall can't find them either. I get Cannot uninstall requirement lockfile-from-pip, not installed and I guess I will just delete the directories and hope that's clean. Source
So what's the preferred way for me to get access to the PyPI lockfile module?

Categories