Cannot install enum package on Python3.6 - pip

I am trying to run this example on MacOS High Sierra. It requires installing the page package, which requires installing the pytodos package, which requires installing the enum package, installation of which fails.
$ python3 page_object_test_case.py
Traceback (most recent call last):
File "page_object_test_case.py", line 3, in <module>
import page
ModuleNotFoundError: No module named 'page'
$ pip3 install page
...
Successfully installed click-6.7 page-1.0.16
$ python3 page_object_test_case.py
Traceback (most recent call last):
File "page_object_test_case.py", line 3, in <module>
import page
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/page/__init__.py", line 2, in <module>
from pytodos import todo
ModuleNotFoundError: No module named 'pytodos'
$ pip3 install pytodos
Collecting pytodos
...
Collecting enum==0.4.6 (from pytodos)
Downloading https://files.pythonhosted.org/packages/0c/4e/1ea357e7783c756bb579333c1e4a026fb331371ee771f616ffedc781e531/enum-0.4.6.tar.gz
Complete output from command python setup.py egg_info:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/version.py:1: UserWarning: Module enum was already imported from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py, but /private/var/folders/h3/1znktv0s36j1fdqcdrr0zvcw0000gn/T/pip-install-jhfn7vc3/enum is being added to sys.path
import pkg_resources
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/h3/1znktv0s36j1fdqcdrr0zvcw0000gn/T/pip-install-jhfn7vc3/enum/setup.py", line 24, in <module>
version = main_module.__version__
AttributeError: module 'enum' has no attribute '__version__'
Note that I've tried to do the same on Ubuntu. And I had to repeat every step. However, installation of enum failed with this error instead:
AttributeError: module 'enum' has no attribute 'IntFlag'
What am I doing wrong?

You went wrong at pip install page.
You were supposed to provide your own module page.py, as described here.
pip install page pulled in some garbage and unrelated/unmaintained projects from PyPI.

Related

Problem installing importlib on Mac with pip3

Good morning!
Until yesterday I was using python 2.7 and using the following code for writing output files for my scripts:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
But now I'm upgrading my code to python 3.7, so now I need to use importlib.reloadinstead of just reload. However, typing sudo -H pip3 install importlib on my shell gives me the following error:
Collecting importlib
Using cached https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 16, in <module>
from distutils.dist import Distribution
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 19, in <module>
from distutils.util import check_environ, strtobool, rfc822_escape
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/util.py", line 9, in <module>
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-3cz_3d6n/importlib/
After looking for solutions I also tried to upgrade setuptools, but that didn't fix my problem.
Many thanks in advance!
importlib at PyPI is an outdated package intended for very old Python versions. For new versions of Python importlib is a module from the standard library, you don't need to install it, it's always available.

Cannot install module 'docstring'

I'm new to Python (coming from C++), running some test code in Brackets. Now pylint complains saying:
C0111 > Missing module docstring [missing-docstring # 1,0]
so I tried installing it:
Manuelas-MacBook:~ manu$ sudo -H pip install docstring
Collecting docstring
Downloading docstring-0.1.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-ex4m9h3o/docstring/setup.py", line 2, in <module>
import docstring
File "/private/tmp/pip-build-ex4m9h3o/docstring/docstring/__init__.py", line 11, in <module>
from utils import Endpoint
ModuleNotFoundError: No module named 'utils'
So I installed utils:
sudo -H pip install utils
Now I am stuck with this:
Manuelas-MacBook:~ manu$ sudo -H pip install docstring
Collecting docstring
Using cached docstring-0.1.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-5bn12ekx/docstring/setup.py", line 2, in <module>
import docstring
File "/private/tmp/pip-build-5bn12ekx/docstring/docstring/__init__.py", line 11, in <module>
from utils import Endpoint
ImportError: cannot import name 'Endpoint'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-5bn12ekx/docstring/
And I don't really know how to go from here.
I had recently installed python3 (on Mac). Could I have a version collision?
Manuelas-MacBook:~ manu$ python --version
Python 3.6.0 :: Anaconda 4.3.1 (x86_64)
Manuelas-MacBook:~ manu$ pip --version
pip 9.0.1 from /Users/manu/anaconda/lib/python3.6/site-packages (python 3.6)
The error message is quite unclear. Acutally, pylint doesn't need any extra module : it just wants you to document your module.
You may want to take a look at this question to disable this warning.
The other answer seem to be probably helpful as I am getting exactly the same problem on my box (Linux Mint, Python 3.6). The reason may be that docstring is not (yet) compatible with Python3 .
Collecting docstring
Using cached docstring-0.1.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-v8oxns74/docstring/setup.py", line 2, in <module>
import docstring
File "/tmp/pip-build-v8oxns74/docstring/docstring/__init__.py", line 11, in <module>
from utils import Endpoint
ImportError: cannot import name 'Endpoint'

Install dbf- no module named enum

I am trying to install the dbf module- see below link.
https://pypi.python.org/pypi/dbf
When I install the module in the Command Prompt, I receive the following invalid syntax error:
C:\Users\dbf-0.96.005>python setup.py install
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running install
running build
running build_py
running install_lib
byte-compiling C:\Python27\Lib\site-packages\dbf\ver_33.py to ver_33.pyc
File "C:\Python27\Lib\site-packages\dbf\ver_33.py", line 2577 raise DbfError<"unable to write updates to disk, original data restored: %r"X<exc,>> from None
^
SyntaxError: invalid syntax
running install_egg_info
Removing C:\Python27\Lib\site-packages\dbf-0.96.005-py2.7.egg-info
Writing C:\Python27\Lib\site-packages\dbf-0.96.005-py2.7.egg-info
C:\Users\dbf-0.96.005>
Then, if I try to import dbf in Interpreter, I get:
Traceback (most recent call last):
File "W:/Engineering/ENGINEER/LAMP (062012)/Database/VisualDatabase/test", line 1, in <module>
import dbf
File "C:\Python27\ArcGIS10.3\lib\site-packages\dbf\__init__.py", line 11, in <module>
from dbf import ver_2 as _dbf
File "C:\Python27\ArcGIS10.3\lib\site-packages\dbf\ver_2.py", line 49, in <module>
from enum import Enum, IntEnum
ImportError: No module named enum
>>>
Do I need to install Enum? Is there a version of Enum I need?
Sorry, I must have foobarred the last package I created.
Do a
pip install enum34
first.

Python No module named, even though the module does appear

Good day.
I've been using
pip install simplecv
to install the module simplecv.
I know the module was properly installed and when I'm printing list of the modules using
#!/usr/bin/env python2.7
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
I can see it in the list : 'simplecv==1.3'
But for some reason I can't use it.
I've tried to export the path using
1) export PYTHONPATH="/usr/local/lib/python2.7"
2) export PYTHONPATH="/usr/local/lib/python2.7/site-packages"
3) export PYTHONPATH="/usr/local/lib/python2.7/dist-packages"
But nothing works
Any ideas?
The package name isn't the same as the module name. The module is called SimpleCV, as shown in the documentation. So we have
>>> import simplecv
Traceback (most recent call last):
File "<ipython-input-2-064db77601b3>", line 1, in <module>
import simplecv
ImportError: No module named simplecv
but
>>> import SimpleCV
Traceback (most recent call last):
File "<ipython-input-3-d3da1d75bea1>", line 1, in <module>
import SimpleCV
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/__init__.py", line 3, in <module>
from SimpleCV.base import *
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/base.py", line 59, in <module>
raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
ImportError: Cannot load OpenCV library which is required by SimpleCV
I didn't bother installing the dependencies, so this didn't work, but if I had, it would have. :-)

Pylint Error - no module named astroid

I've recently installed pylint on a windows 7 and when I run it I get the error:
Error executing PyLint: Command failed with error=None, status=1; stderr:
Traceback (most recent call last):
File "C:\Python27\Scripts\pylint", line 3, in <module>
run_pylint()
File "c:\python27\lib\site-packages\pylint\__init__.py", line 20, in run_pylint
from pylint.lint import Run
File "c:\python27\lib\site-packages\pylint\lint.py", line 30, in <module>
from pylint.checkers import utils #pylint: disable=unused-import
File "c:\python27\lib\site-packages\pylint\checkers__init__.py", line 47, in
from pylint.reporters import diff_string
File "c:\python27\lib\site-packages\pylint\reporters__init__.py", line 20, in
from pylint.utils import MSG_TYPES
File "c:\python27\lib\site-packages\pylint\utils.py", line 32, in
from astroid import nodes, Module
ImportError: No module named astroid
I've followed the install instructions as best I can but can't seem to get past this.
Use this link to install pip properly How do I install pip on Windows?
then do the pip install pylint
then do go through this note http://docs.pylint.org/installation.html#note-for-windows-users

Resources