issue with python 3.4+ and pip - 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.

Related

Airflow Installation issue| setproctitle

I Have followed the below steps for airflow installation and have successfully installed but am unable to run any commands which start with airflow, even to check the version. Any help is appreciated.
python3.9 -m venv airflowenv ,
source airflowenv/bin/activate export ,
AIRFLOW_HOME=~/airflow ,
echo $AIRFLOW_HOME ,
pip install --upgrade pip ,
pip install apache-airflow==1.10.15 ,
airflow initdb.
This is the error am receiving:
Traceback (most recent call last):
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/__init__.py", line 50, in <module>
from airflow.models import DAG # noqa: E402
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/__init__.py", line 21, in <module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 43, in <module>
from airflow.models.dag import DAG
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/dag.py", line 47, in <module>
from airflow.executors import LocalExecutor, get_default_executor
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/executors/__init__.py", line 23, in <module>
from airflow.executors.base_executor import BaseExecutor # noqa
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 24, in <module>
import airflow.utils.dag_processing
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/utils/dag_processing.py", line 40, in <module>
from setproctitle import setproctitle
ImportError: dlopen(/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
Referenced from: /Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
Expected in: flat namespace
in /Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so```
---------------------------------------------------------------------*********************************************************************
SOLUTION:[Followed these steps to fix the issue]:
Install python3.9 from the python website
python3.9 -m venv envpython
source envpython/bin/activate
export AIRFLOW_HOME=~/airflow
echo $AIRFLOW_HOME
pip install apache-airflow==1.10.15 --constraint https://raw.githubusercontent.com/apache/airflow/constraints-1.10.15/constraints-3.8.txt
airflow initdb
airflow webserver
airflow scheduler
*********************************************************************
If you are on MacOS, you need to install Python 3.8 manually following https://www.python.org/downloads/.
See Import issue for setproctitle on Mac OS,
You should use constraints when installing Airflow. See this link that explains why: https://airflow.apache.org/docs/apache-airflow/stable/installation.html#constraints-files
In your case, the correct command will be:
pip install apache-airflow==1.10.15 --constraint https://raw.githubusercontent.com/apache/airflow/constraints-1.10.15/constraints-3.8.txt

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.

ImportError: No module named 'thinc.about'

I am trying to install spacy for windows, python 3.x.
I ran the following commands:-
conda install -c conda-forge spacy
python -m spacy download en
"python -m spacy download en" gives the error:-
Traceback (most recent call last):
File "D:\Anaconda3\lib\runpy.py", line 174, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "D:\Anaconda3\lib\runpy.py", line 133, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "D:\Anaconda3\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "D:\Anaconda3\lib\site-packages\spacy\__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "D:\Anaconda3\lib\site-packages\spacy\cli\__init__.py", line 1, in <module>
from .download import download
File "D:\Anaconda3\lib\site-packages\spacy\cli\download.py", line 10, in <module>
from .link import link
File "D:\Anaconda3\lib\site-packages\spacy\cli\link.py", line 7, in <module>
from ..compat import symlink_to, path2str
File "D:\Anaconda3\lib\site-packages\spacy\compat.py", line 11, in <module>
from thinc.neural.util import copy_array
File "D:\Anaconda3\lib\site-packages\thinc\__init__.py", line 1, in <module>
from .about import *
ImportError: No module named 'thinc.about'
and the same error when I try to import spacy thereafter. What should I do to successfully install spacy?
I found this link from where I downloaded all of the required whls one by one to install spacy.
Compiling wheel rather than downloading ready one might be helpful as well:
python -m pip install thinc --no-binary=:all:
or
pip install thinc --no-binary=:all:
Don't forget to add --force option if you already have the package.
More information about --no-binary option:
https://pip.pypa.io/en/latest/cli/pip_install/#cmdoption-no-binary

Twilio import error in python shell

Installed Twilio successfully however when I attempt to import it in either the shell or terminal I get this error output:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import twilio
File "/Library/Python/2.7/site-packages/twilio/__init__.py", line 11, in <module>
from .rest.exceptions import TwilioRestException
File "/Library/Python/2.7/site-packages/twilio/rest/__init__.py", line 1, in <module>
from .base import set_twilio_proxy
File "/Library/Python/2.7/site-packages/twilio/rest/base.py", line 6, in <module>
from twilio.rest.resources import Connection
File "/Library/Python/2.7/site-packages/twilio/rest/resources/__init__.py", line 1, in <module>
from .util import (
File "/Library/Python/2.7/site-packages/twilio/rest/resources/util.py", line 5, in <module>
import pytz
ImportError: No module named pytz
Can anyone explain what is happening here? My version of Python is 2.7.9 and my pip installer is current as well. Output Error above is from importing in IDLE shell.
Twilio developer evangelist here.
The Twilio library requires pytz to be installed. Easiest way to get it installed is by running this on your terminal:
pip install pytz
Hope this helps

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