AttributeError: Module 'pip' has no attribute 'logging' [duplicate] - python

I am writing because I am having trouble installing Pyomo using pip on Python 3.6 on Mac OSX 10.14
I'm following the installation instructions here.
I can successfully execute the first command:
pip install pyomo
But when I run into trouble when I'm supposed to run the following command to install additional dependencies:
pyomo install-extras
Running this command produces the following error:
Traceback (most recent call last):
File "/usr/local/bin/pyomo", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/pyomo/scripting/pyomo_main.py", line 82, in main
retval = _options.func(_options)
File "/usr/local/lib/python3.6/site-packages/pyomo/scripting/driver_help.py", line 46, in install_extras_exec
pyutilib.subprocess.run(command, tee=True)
File "/usr/local/lib/python3.6/site-packages/pyutilib/subprocess/processmngr.py", line 690, in run_command
th.join()
UnboundLocalError: local variable 'th' referenced before assignment
There is a post about this here on Google Groups but no solution yet.

This is a documented issue on the github for Pyomo: https://github.com/Pyomo/pyomo/issues/243
They don't appear to have solved the pip installation of pyomo extras.
However, if you have conda installed - https://docs.conda.io/en/latest/
You should be able to use the terminal commands from:
https://pyomo.readthedocs.io/en/latest/installation.html
run this in terminal after conda has been successfully installed:
conda install -c conda-forge pyomo.extras
I know this isn't pip, but it's at least a workaround until pyomo fixes their documentation.
confirmed working on python 3.x and ubuntu 18.04

I got the problem too (in Ubuntu 18.04).
Try installing it from the git project (https://github.com/Pyomo/pyomo):
In Ubuntu 18.04:
git clone https://github.com/Pyomo/pyomo.git
python3 pyomo/scripts/get_pyomo_extras.py
Use the corresponding commands for Mac OSX (I had never used it).
I hope that it works for you.

Related

Cannot Run Jupyter Notebook on Terminal

for my homework we need to use jupyter notebook to run an .ipynb file. I use Mac and I used pip install jupyter to install it using terminal, which was successful. However when I tried to open it using the commandjupter notebook I get this error. Any ideas? Thanks.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 5, in
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 76, in
from .base.handlers import Template404, RedirectWithParams
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/base/handlers.py", line 24, in
import prometheus_client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/init.py", line 3, in
from . import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 43, in
GC_COLLECTOR = GCCollector()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 14, in init
registry.register(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 26, in register
names = self._get_names(collector)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 66, in _get_names
for metric in desc_func():
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 36, in collect
collected.add_metric([generation], value=stat['collected'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/metrics_core.py", line 126, in add_metric
self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp))
TypeError: new() missing 1 required positional argument: 'exemplar'
From your terminal out screen grab, I can see that you are not in a virtual environment which would mean that you are using global python.
Three things to check and or consider:
1. Python Version (management and checking).
To avoid the type of error that you are seeing- creating dependency issues of your versions of python, it may be an idea to use a package manager like conda or use virtual environments and install within them.
2. Proper use of pip install:
If you do not want to use vnev's or a package manager like conda perhaps double-check that you have installed on the correct version of python and install jupyter on the version of python you want to use.
python3.6 -m pip install jupyter
3. Environment Management:
There are a number of different options for managing the python version some people like to create virtual environments within your present working directory and active them using:
python3.6 -m pip install virtualenv
python3.6 -m venv env_name
source env_name/bin/activate
Once activated your terminal will show:
(env_name) jeffmpro....
You can then pip install jupyter inside this environment and this will then run using:
jupyter notebook
If you want to manage the python version and virtual environments globally using shims you can do this using a package called pyenv:
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv
I would also use homebrew on mac to manage installations in the command line.
https://brew.sh/
Hope this helps :-)
The correct answer is actually what came out in the comments, I'll report it here for future viewers:
pip install jupyter
pip install notebook
jupyter-notebook your-file.ipynb
See you!

How do I solve the issue "No module name Botan"

I am using windows 8 and python 3.6.1 I've done the following command in my cmd:
pip install cryptoshop
However, when I run the following python code:
from cryptoshop import encryptfile
from cryptoshop import decryptfile
result1 = encryptfile(filename="test", passphrase="mypassphrase", algo="srp")
print(result1)
result2 = decryptfile(filename="test.cryptoshop", passphrase="mypassphrase")
print(result2)
I get the following error:
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/test.py", line 1, in
from cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop__init__.py", line 26, in
from cryptoshop.cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop\cryptoshop.py", line 56, in
from ._cascade_engine import encry_decry_cascade
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_cascade_engine.py", line 27, in
from ._nonce_engine import generate_nonce_timestamp
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_nonce_engine.py", line 39, in
import botan
ModuleNotFoundError: No module named 'botan'
Now, I obviously know that you must install botan into python in order to use it. However, this is where I am running into an issue. I've downloaded Botan from this link as instructed:
https://github.com/randombit/botan
And then I've followed these instructions in an attempt to install Botan:
./configure.py [--prefix=/some/directory]
make
make install
However, when I type make into the command line I get an error saying there is no such command. And then when I go to run my above Python code I still get the no module Botan error. So obviously I am doing something run. How can I properly install Botan into my Python 3.6 directories so that I can use cryptoshop.
I've also attempted to do pip install Botan, as that is how I've installed so many other python libraries but that has been unsuccessful as well.
make is a linux command
According to the botan website you can use nmake as a replacement on windows ( http://wiki.c2.com/?UsingNmake ) :
On Windows
You need to have a copy of Python installed, and have both Python and
your chosen compiler in your path. Open a command shell (or the SDK
shell), and run:
$ python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]
$ nmake
$ botan-test.exe
$ nmake install
Botan supports the nmake replacement Jom which enables you to run
multiple build jobs in parallel.
source : https://botan.randombit.net/manual/building.html
For completeness, here's how I made it work on a Mac
Assuming you have brew installed.
brew install botan
You may need to install other functionality first:
brew install gmp
brew install mpfr
brew install mpc
Find out where botan got installed with brew info botan.
My location is /usr/local/Cellar/botan/2.6.0
In that folder, you'll find lib/python2.7/site-packages, copy the contents of this folder into your Python's installation site-packages folder.
Note 1: At the time of this writing, only python 2.7 seems to be supported, but I'm using python 3.6 and everything seems to be working.
Note 2: If the file is called botan2.py, you may need to rename it to botan.py in your python's site-packages folder.

Failure: Centos 6.4 python easy_install is broken

I've looked at quite a lot of related questions here - no help for me. I need to repair easy_install, so that I can update distribute to a version >=0.6.28, so that I can update python matplotlib using pip and not yum.
In the process of trying to update python matplotlib from 0.99 (the default with Centos64) to 1.4.x, I got into this trouble:
pip install --upgrade matplotlib tells me this:
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.10 (/usr/lib/python2.6/site-packages))
So I followed the suggestion and saw that some 0.7.x version of distribute was installed (so it seemed). Re-ran the pip command and got the exact same complaint.
Trouble with easy_install?
It was either now, or maybe after performing yum remove, then install python-setuptools that I discovered easy_install is thoroughly broken. Now when I try to run easy_install, I get this stacktrace:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 9, in <module>
load_entry_point('distribute', 'console_scripts', 'easy_install')()
File "/usr/local/lib/python3.3/site-packages/setuptools-18.2-py3.3.egg/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.3/site-packages/setuptools-18.2-py3.3.egg/pkg_resources/__init__.py", line 2681, in load_entry_point
raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found
Look at that - why is it referring to python3.3? I don't think I've got that installed. My default python is 2.6.6.
Any ideas? TIA.
Fixed it. The python3.3 bit was my clue. I found the python script for easy_install, in /usr/local/bin. The very first line designated /usr/bin/python3.3 to execute the script. Changed to 2.6 and then was good to go.
In the end I was not able to upgrade matplotlib from 0.99 to 1.4.3, because I could not upgrade basemap from 0.99 and some conflicts arose. Rather than punish myself with trying to build from source, I think I should simply upgrade my entire VM to Centos7 and I will then have much newer matplotlib.

Easy_install and Pip doesn't work

Easy_install and Pip doesn't work anymore on python 2.7, when I try to do:
sudo easy_install pip
I get:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
And when I try:
sudo pip install [package]
I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
I've already install both of them (and yes, first deleted them), but no result...
Thanks!
(I tried already this post)
I had this issue where python's distribute package wasn't installed for some reason. After following the instructions on python-distribute, i got it working.
install the distribute package as follows:
$ wget https://web.archive.org/web/20100225231201/http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
EDIT: http://python-distribute.org/distribute_setup.py no longer works:
hopefully this will resolve your problem with running
$ sudo easy_install
Happy Coding!
If you installed a new version of easy_install through Distribute, the new command may have been installed in another directory, most likely /usr/local/bin/. But the traceback shows you were using /usr/bin/easy_install. Try this:
sudo /usr/local/bin/easy_install ...
Try
sudo easy_install Distribute
and if that exists, but is too old
sudo easy_install -U Distribute
Looks like either Distribute/setuptools (it's old name) is messed up or Python package settings. If either of these do not help, try removing the full Python 2.7 installation and reinstall everything from the scratch.
Possible reasons for the mess is that you have used both sudo easy_install / sudo pip and Linux distribution packages to mix and match system-wide installation packages. You should use virtualenv instead if you use pip/easy_install (no sudo needed)
http://pypi.python.org/pypi/virtualenv
I had a similar problem, but things were working fine as root. In my case, I found that the permissions on the python packages were not readable by the ID I was running the command under.
To correct it, I ran the following command to open the permission for read and execute to all users:
sudo chmod o+rx -R /usr/local/lib/python2.7/dist-packages/*.egg
I had similar issue when trying to install package via pip with python 3.6 on windows. (pip is supposed to work out of the box with this install)
The problem was not running as administrator.
Running cmd as administrator and then installing my package worked:
python -m pip install pylint
I was trying to get pip to work on the 2.7.0 version, but it seems like it doesn't come with the easy_install/pip files (Script folder in main directory), installing 2.7.13 solved the problem for me.

Problems installing MySQL-python-1.2.3c1 on Mac Snow Leopard

I am having a problem installing the Python MySQL connector (MySQL-python-1.2.3c1) on my Mac OSX Snow Leopard.
System State
I have manually compiled an installed:
mysql-5.1.41
This seems to work fine, as I can create and query a database from the commandline.
I have compiled:
MySQL-python-1.2.3c1
I first set the following in the site.cfg file:
mysql_config = /usr/local/mysql/bin/mysql_config
I then built and compiled MySQL-python-1.2.3c1 following their guide:
sudo python setup.py build
sudo python setup.py install
I now test the installation with Python:
python -c "import MySQLdb"
Error Message
This then gives me the following error, and I'm stumped as to how to fix it:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Expected in: flat namespace
in /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
mymac: username$
Things I've Tried
I've looked at this blog antoniocangiano.com but it is for an older version of MySQL-python and is not really applicable. But I tried adding the soft link it mentions.
I then looked at this blog post: http://blog.some-abstract-type.com/2009/09/mysql-python-and-mac-os-x-106-snow.html. And tried building compiling with the ARCHFLAGS settings - but no joy.
Please Help
If you have any ideas please let me know.
Many thanks
Ben...
First, I would suggest using the MySQL binaries for MacOS X 10.5 64-bit (x86_64). The tar ball works on MacOS X 10.6.
You said you used ARCHFLAGS.. however, try it again like this:
shell> ARCHFLAGS="-arch x86_64" python setup.py build
shell> sudo python setup.py install
Thus building as normal user, installing as root. (It's good to remove the source, and unpack correcting the site.cfg file again).
What does
otool -L /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
report?

Categories