python 2.7 OSX 10.10 package problems - macos

I'm using :
mac osx 10.10.1
Yesterday I started to get errors using same packages that I normally use.
After few hrs I decided to remove python from my mac
I installed python again following this instructions:
http://docs.python-guide.org/en/latest/starting/install/osx/#install-osx
(i a nut shell I installed python 2.7 using HomeBrew)
from the shell:
$python
Python 2.7.8 (default, Oct 19 2014, 16:02:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from the shell:
$ which python
/usr/local/bin/python
from the shell:
$ which -a python
/usr/local/bin/python
/usr/local/bin/python
I installed pip
I installed few pkgs using $ pip install command
when I try to just import openpyxl
I'm getting this:
import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/openpyxl/__init__.py", line 27, in <module>
from openpyxl.workbook import Workbook
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/__init__.py", line 25, in <module>
from .workbook import *
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 11, in <module>
import threading
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 14, in <module>
from time import time as _time, sleep as _sleep
ImportError: cannot import name time
please can you help me out?
thanks
d
additional info:
meanwhile I tried to do same thing else to fix the problem
(I didn't fix it)
Basically I installed virtualenv
I created a basic virtual env
I have a new folder with python and all the pkgs
(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ which python
/Users/danielepemy/my_python_virtualenv/venv_002/bin/python
everything looks fine, python works, pip works the pkgs are listed in the virtual env
(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ pip list
pip (1.5.6)
setuptools (3.6)
wsgiref (0.1.2)
XlsxWriter (0.6.4)
when I run a simple test script with XlsxWriter I get:
python ..//internet_speed_test_002.py
Traceback (most recent call last):
File "..//internet_speed_test_002.py", line 28, in <module>
excel_file.close()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 286, in close
self._store_workbook()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 509, in _store_workbook
xml_files = packager._create_package()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 142, in _create_package
self._write_core_file()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 325, in _write_core_file
core._assemble_xml_file()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 57, in _assemble_xml_file
self._write_dcterms_created()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 122, in _write_dcterms_created
date = self._localtime_to_iso8601_date(date)
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 76, in _localtime_to_iso8601_date
return date.strftime("%Y-%m-%dT%H:%M:%SZ")
AttributeError: 'module' object has no attribute 'struct_time'

Do you have any files called time.py or time.pyc in your current directory? If so, rename or delete them (.pyc files can simply be deleted).

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.

catch_config_error while trying to run ipython3

I'm getting the following error trying to run ipython3.
catch_config_error() missing 1 required positional argument: 'app'
I first got it on my Mac (python36). As my system has all sorts of customizations, I tried it again on a Linux system (Centos 7.4). I install ipython using pip3 and everything seemed to install cleanly. (On the same system, if i do this with python2, it seems to work.
Complete error log:
[scott] ipython3
Traceback (most recent call last):
File "/usr/bin/ipython3", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/usr/lib/python3.4/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
File "/usr/lib/python3.4/site-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/usr/lib/python3.4/site-packages/traitlets/config/application.py", line 120, in <module>
class Application(SingletonConfigurable):
File "/usr/lib/python3.4/site-packages/traitlets/config/application.py", line 291, in Application
def initialize(self, argv=None):
TypeError: catch_config_error() missing 1 required positional argument: 'app'
This is happening because traitlets relies on a package called 'decorator' that was just updated from 4.1.2 to 4.2.0 and broken its backward compatibility.
If you're using a requirements file or pip, install decorator==4.1.2 before installing IPython.
I tried in Ubuntu 16.04.
I also had the same problem (Python 3.6)
I tried again today.
$ sudo -H pip3 install --upgrade ipython
Then, decorator 4.2.1 is newly installed and the problem is solved.

Tensorflow install on Windows with anaconda and no internet connection

I can not install Tensorflow on Windows because there in no internet connection based on commpany's security policy.
I just installed anaconda and python by transmiting files with intranet.
Please let me know how to install that with no internet connection.
==========================================================================
In addition, when I used the below command after installing tensorflow, I found
other problems..
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 63, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google'
I don't know how to solve this one.
If you can download the whl file and transfer it to your workstation, then you can run:
pip.exe install --upgrade --no-deps <tensorflow whl file name>
This should avoid trying to connect to download tensorflow dependencies, as anaconda already has most of these.

Symbol not found: _PQclear (caldav server tools broken after Mavericks update on OSX Server)

After upgrading my server to Mavericks and Server.app version 3, those tools stopped to work properly :
calendarserver_export
calendarserver_manage_principals
...
When I enter this command, for example :
sudo calendarserver_export -u <account_name>
then this error is displayed :
Traceback (most recent call last):
File "/Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_export", line 32, in <module>
from calendarserver.tools.export import main
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/calendarserver/tools/export.py", line 50, in <module>
from calendarserver.tools.cmdline import utilityMain, WorkerService
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/calendarserver/tools/cmdline.py", line 21, in <module>
from calendarserver.tap.caldav import CalDAVServiceMaker, CalDAVOptions
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/calendarserver/tap/caldav.py", line 87, in <module>
from twistedcaldav.upgrade import UpgradeFileSystemFormatStep, PostDBImportStep
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/twistedcaldav/upgrade.py", line 63, in <module>
from calendarserver.tap.util import getRootResource, FakeRequest, directoryFromConfig
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/calendarserver/tap/util.py", line 87, in <module>
from txdav.base.datastore.subpostgres import PostgresService
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/txdav/base/datastore/subpostgres.py", line 35, in <module>
import pgdb
File "/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/pgdb.py", line 66, in <module>
from _pg import *
ImportError: dlopen(/Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/_pg.so, 2): Symbol not found: _PQclear
Referenced from: /Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/_pg.so
Expected in: flat namespace
in /Applications/Server.app/Contents/ServerRoot/usr/share/caldavd/lib/python/_pg.so
All these tools have in common to access the caldav data via python, through PyGreSQL (caldav data is hosted in a postgres database).
I managed to reproduce very simply this problem by :
#login with root
bob $ sudo -i
#launch python and import pg (postgres module for python)
root $ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/PyGreSQL-4.1.1-py2.7-macosx-10.9-intel.egg/pg.py", line 31, in <module>
from _pg import *
ImportError: dlopen(/Library/Python/2.7/site-packages/PyGreSQL-4.1.1-py2.7-macosx-10.9-intel.egg/_pg.so, 2): Symbol not found: _PQclear
Referenced from: /Library/Python/2.7/site-packages/PyGreSQL-4.1.1-py2.7-macosx-10.9-intel.egg/_pg.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/PyGreSQL-4.1.1-py2.7-macosx-10.9-intel.egg/_pg.so
BUT, if I launch python from my user account (not root), I don't get the error.
I assume there is something wrong with the path, or something similar, but I can't find what...
I need to have root credentials to be able to use **calendarserver_export**
Any clues ??
For some reason, in mavericks, you have to launch these commands with the "calendar" user (alias of _calendar).
So the command should be :
sudo -u calendar calendarserver_export -u

issue with python 3.4+ and pip

I installed pip 3.4 recently , however i cant seem to use pip properly ( which is included with the latest python 3) it gives me this error whenever i attempt to import it :
"Traceback (most recent call last)
File "<pyshell#8>", line 1, in <module>
import pip
File "C:\Python34\lib\site-packages\pip\__ini... line 9, in <module>
from pip.log import logger
File "C:\Python34\lib\site-packages\pip\log.p... line 8, in <module>
from pip import backwardcompat
File "C:\Python34\lib\site-packages\pip\backw... line 27, in <module>
console_encoding = sys.__stdout__.encoding
AttributeError: 'NoneType' object has no attribute 'encoding"``
If you are using python under WIN OS, pip works as a WIN command: try to directly type "pip install .package." in your cmd shell.

Resources