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
Related
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.
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.
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.
I'm just getting started with python. After installing python (3.6.8) and running VS code to learn some scripts, I found out that intellisense is not giving any suggesions for packages that I installed by pip
ex:
import numpy as np
x=np.ar(nothing shows here and even before typing the "ar", just shows a bunch of stuff that I typed earlier)
I'm sorry if I'm missing something, I'm literally a newbie.
Thank you.
Make sure that you selected the appropriate interpreter and environment that you installed into. Also make sure that the extension has finished loading and analyzing packages. Finally, you can use the Microsoft language server if you aren't already to see if it gives you better results than Jedi.
I need to install and use the Python NumPy module (and then later the Pandas module) in order to process heavy data in Python.
I downloaded and installed ENTHOUGHT, but it wasn't what I wanted all that extra clutter of extra modules (which defeats the purpose of importing Python modules only as needed), but the uninstall did not work properly (i.e. it left garbage folders and ENTHOUGHT remnants all over my computer).
I have tried installing NumPy via EASY_INSTALL and PIP (two package managers if I understand correctly) - but with no success. Every time I try to run my program, I get the error: "no module named numpy".
I have searched the questions here and have tried to alter my ENVIRONMENT VARIABLE as per the following video, but again, no success:
https://www.youtube.com/watch?v=ddpYVA-7wq4
C:\Python34
...still the same error!
I downloaded Anaconda (with all its extra clutter and installed, but I don't like the development environment - I want my Vanilla Python IDLE to run Vanilla NumPy with no extra clutter modules...) and when I tried to again install Numpy I received a message that it was already installed with a path to:
C:\users\yoni\anaconda3\lib\site-packages
....so I ALSO added this PYTHONPATH to the ENVIRONMENT VARIABLE in hopes that it would now recognize where the NumPy installation was (currently with Anaconda3 - but I hoped to be able to import NumPy to my vanilla Python IDLE):
C:\Python34;C:\users\yoni\anaconda3\lib\site-packages
I don't find a clear answer - I see others have the same problem, and nothing is working for me. How can I finish this installation of NumPy so that it works for me when I do a simple import of module?
This is a temporary solution until you can resolve your path issue.
It will be environment specific.
import sys
sys.path.append('C:\users\yoni\anaconda3\lib\site-packages[PackageName]')
import PakcageName