z3-solver installed functions not working - z3py

I installed z3 and the z3-solver components via pip using
pip install z3 and pip install z3-solver
then in my Jupyter notebook I test the following code and error
from z3 import *
x = Int('x')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-124-ef7631f40ab0> in <module>
1 from z3 import *
----> 2 x = Int('x')
NameError: name 'Int' is not defined
I do not have any file called z3.py or z3.*

You can Try Installing Both
$ pip3 install z3-solver
$ pip3 install z3

Related

Is IDLE a console? [duplicate]

This question already has answers here:
python3 --version shows "NameError: name 'python3' is not defined"
(2 answers)
Closed 27 days ago.
I want to check whether pip is installed, but I don't know how to do that.
I tried typing pip into IDLE:
ModuleNotFoundError: No module named 'matplotlib'
>>> pip
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
pip
NameError: name 'pip' is not defined
>>>
Don't use IDLE to run pip. Check if you have pip installed by opening up command prompt and typing pip help or pip --version If you get an error it's obviously not installed.
To update pip, enter python -m pip install -U pip.

Pyserial installation troubleshooting

On macOS Monterey:
pip3 install pyserial
import serial returned :
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'serial'
The command:
sudo python3 -m pip install pyserial
solved the serial error. What is the difference? Why did the latter command work (and not the former)?
https://stackoverflow.com/a/63864708/4953146

basic mlxtend example giving invalid syntax error

I'm using Python 3.5.2 on Ubuntu 16.04.
I've installed sklearn using..
sudo apt install python-sklearn
and mlxtend using...
sudo pip3 install mlxtend
I'm trying to run the basic Iris example found on the Internet, but I am getting an error as soon as I try to import plot_decision_regions from mlxtend.plotting:
from mlxtend.plotting import plot_decision_regions
Traceback (most recent call last):
File "scripts/machine.learning.py", line 6, in <module>
from mlxtend.plotting import plot_decision_regions
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
from .heatmap import heatmap
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
raise AssertionError(f'len(row_names) (got {len(row_names)})'
^
SyntaxError: invalid syntax
I had the same error, just upgrade to python3.7 the real error is
python 3.5 does not support f prefix
upgrade using conda
conda install -c anaconda python=3.7
and then update all depencies
conda update --all
I'm not seeing the same error as you, but try remove legend=range(105, 150) from plot_decision_regions i.e.
plot_decision_regions(x_combined, y_combined, clf=tree)
I'm using the latest current sklearn, i.e.
import sklearn
sklearn.__version__
'0.21.3'
Perhaps remove that version
sudo apt-get remove python-sklearn
Then install via pip, i.e.
pip3 install scikit-learn

DLVM - pip install error

Trying to pip install on Azure Deep Learning VM is giving this error-
Complete output from command python setup.py egg_info:
ERROR:root:Error parsing
Traceback (most recent call last):
File "/anaconda/envs/py35/lib/python3.5/site-packages/pbr/core.py", line 111, in pbr
attrs = util.cfg_to_args(path, dist.script_args)
File "/anaconda/envs/py35/lib/python3.5/site-packages/pbr/util.py", line 267, in cfg_to_args
wrap_commands(kwargs)
File "/anaconda/envs/py35/lib/python3.5/site-packages/pbr/util.py", line 569, in wrap_commands
cmdclass = ep.resolve()
File "/anaconda/envs/py35/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 2264, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named 'setuptools.command.build_clib'
error in setup command: Error parsing /tmp/pip-build-9ucgxr1d/cliff/setup.cfg: ImportError: No module named 'setuptools.command.build_clib'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9ucgxr1d/cliff/
Given the paths above it appears this is happenning on the Python 3.5 (py35) conda environment on the Linux edition of the Azure Data Science VM (DSVM) and Deep Learning VM (DLVM).
Based on the error message, the general guidance to resolve this is to update the setuptools and then try to install the library.
The commands to do that on the DSVM/DLVM on the global py35 conda environment is:
sudo /anaconda/envs/py35/bin/pip install --upgrade setuptools
sudo /anaconda/envs/py35/bin/pip install <<package name>>
For the root (Python 2.7) environment on the DSVM the commands are:
sudo /anaconda/bin/pip install --upgrade setuptools
sudo /anaconda/bin/pip install <<package name>>
Hope this resolves the issue.

How can I use jython setup.py install?

I am using a Jython virtualenv where I can install whatever software via pip or via easy_install, but there is a software that is not registered yet and the installation mode via:
[sudo] python setup.py install
and I am trying to do the same with jython:
[sudo] jython setup.py install
So, I am getting these follow errors:
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
I checked and installed jython ez_setup.py again.
I downloaded the yolk and didn't solved too.
My folder:
╭─hudson#hudson-pc ~/jython2.7a1/Lib/site-packages ‹› ‹master*›
╰─$ ls
easy-install.pth setuptools.pth yolk 0.4.3-py2.7.egg README should_dsl-2.0a5-py2.7.egg setuptools-0.6c11-py2.7.egg virtualenv-1.7.2-py2.7.egg
And at the normal(real) environment, without virtualenvs, I got the same erros.
At Python I already installed this software and worked well.
If I enter at Jython Shell and try import setuptools, I got the same erros too:
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>> import sys
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__']
Then, I add the site-packages to the sys (It can be a stupid attempt):
>>> sys.path.append('/home/hudson/jython2.7a1/Lib/site-packages')
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__', '/home/hudson/jython2.7a1/Lib/site-packages']
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
Why is not recognizing?
If pip "works" then you could use it to install your software. To try it, run from a directory with setup.py:
$ pip install -e .
If you have a tarball of the package:
$ pip install your_package-0.0.1.tar.gz
pip can install from a git repository, use custom urls from where to get packages, etc.
I've tested it: jython works with virtualenv, distribute (a fork of setuptools), pip. So jython can install a package if it uses setuptools in setup.py.
Basically you need to install the installtool first. To do so see the doc linked below.
install this: http://peak.telecommunity.com/dist/ez_setup.py
(see here:http://www.jython.org/jythonbook/en/1.0/appendixA.html#setuptools)

Resources