I installed anaconda2 over python 2.7 and i am on Windows 10.
when I am trying to use pip , Syntax error is coming. I am using basic cmd to access pip , even without the environment variable thing , it's not working .
Can anybody explain what am I doing wrong ?
Error:
C:\Users\Yash gupta\Anaconda2\Scripts>python
Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:17:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> pip install bs4
File "<stdin>", line 1
pip install bs4
^
SyntaxError: invalid syntax
>>>
you are using pip in python environment.
You must quit python and run pip install bs4 with the shell.
If you want to install the library only in a specific anaconda environment, lunch the source activate <yourEnv> command and then use pip install.
Related
I'm writing a script in python to update some YAML config files containing jinja2. I found this answer showing how to do it using ruamel.yaml and ruamel.yaml.jinja2 packages and it works absolutely fine on windows10 using this configuration:
$ python -V
Python 2.7.5
$ python -m pip list
[...]
ruamel.ordereddict 0.4.13
ruamel.yaml 0.15.94
ruamel.yaml.jinja2 0.2.2
[...]
and this code:
from ruamel.yaml import YAML
yamlLoader = YAML(typ='jinja2')
But when I try to use it on a CentOS virtual machine, which is the target environment for this script, I get this error:
File "/opt/salt/mig/cnamts_migrate.py", line 17, in <module>
yamlLoader = YAML(typ='jinja2')
File "/usr/lib64/python2.7/site-packages/ruamel/yaml/main.py", line 138, in __init__
'typ "{}"not recognised (need to install plug-in?)'.format(self.typ)
NotImplementedError: typ "jinja2"not recognised (need to install plug-in?)
I can't find any difference in neither Python configuration nor packages' version.
On CentOS VM:
$ python -V
Python 2.7.5
$ pip list
Package Version
---------------------------- -----------
pip 19.1
ruamel.ordereddict 0.4.13
ruamel.yaml 0.15.94
ruamel.yaml.jinja2 0.2.2
setuptools 41.0.1
This path
/usr/lib64/python2.7/site-packages/ruamel/yaml/main.py
in the error message gives me the impression that you are using a system wide Python installation. You should (IMHO even in a VM) use python virtualenv for any utility (and preferaby one per non-related utility). You don't show the output of pip for your CentOS machine, which is way more interesting than the one on your Windows box.
$ more /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
$ /opt/python/3.7/bin/python -m venv /tmp/so-55900745
$ source /tmp/so-55900745/bin/activate
(so-55900745) $ pip install ruamel.yaml.jinja2
Collecting ruamel.yaml.jinja2
Downloading https://files.pythonhosted.org/packages/4f/b4/9676d4fa53d921f98f40dcda2ecfdb9fba2b68fbdccec3d9d4d2c87d96a7/ruamel.yaml.jinja2-0.2.2-py2.py3-none-any.whl
Collecting ruamel.yaml>=0.15.10 (from ruamel.yaml.jinja2)
Downloading https://files.pythonhosted.org/packages/bb/e3/8c06f90dab796bd5baf5da2482cf919bab3145389196814ec3180d4c7bd5/ruamel.yaml-0.15.94-cp37-cp37m-manylinux1_x86_64.whl (647kB)
100% |████████████████████████████████| 655kB 9.3MB/s
Installing collected packages: ruamel.yaml, ruamel.yaml.jinja2
Successfully installed ruamel.yaml-0.15.94 ruamel.yaml.jinja2-0.2.2
(so-55900745) $ pip list
Package Version
------------------ -------
pip 19.1
ruamel.yaml 0.15.94
ruamel.yaml.jinja2 0.2.2
setuptools 40.8.0
(so-55900745) $ python
Python 3.7.3 (default, Apr 3 2019, 11:33:06)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ruamel.yaml import YAML
>>> yamlLoader = YAML(typ='jinja2')
>>> exit()
(so-55900745) $ deactivate
$ rm -rf /tmp/so-55900745/
$ virtualenv -p /opt/python/2.7/bin/python /tmp/so-55900745
Running virtualenv with interpreter /opt/python/2.7/bin/python
New python executable in /tmp/so-55900745/bin/python
Installing setuptools, pip, wheel...
done.
$ source /tmp/so-55900745/bin/activate
(so-55900745) $ pip install ruamel.yaml.jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting ruamel.yaml.jinja2
Using cached https://files.pythonhosted.org/packages/4f/b4/9676d4fa53d921f98f40dcda2ecfdb9fba2b68fbdccec3d9d4d2c87d96a7/ruamel.yaml.jinja2-0.2.2-py2.py3-none-any.whl
Collecting ruamel.yaml>=0.15.10 (from ruamel.yaml.jinja2)
Downloading https://files.pythonhosted.org/packages/a2/59/e8cb144511e47e068efdb71a85f35d00b32fc5f05a9e9a17df265ec252b5/ruamel.yaml-0.15.94-cp27-cp27mu-manylinux1_x86_64.whl (600kB)
|████████████████████████████████| 604kB 2.0MB/s
Collecting ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" (from ruamel.yaml>=0.15.10->ruamel.yaml.jinja2)
Downloading https://files.pythonhosted.org/packages/f3/2c/fa6d75dc459b371ed3b88fdbf8042785ce1655073c884fd97bdbb9f48e01/ruamel.ordereddict-0.4.13-cp27-cp27mu-manylinux1_x86_64.whl (99kB)
|████████████████████████████████| 102kB 12.7MB/s
Installing collected packages: ruamel.ordereddict, ruamel.yaml, ruamel.yaml.jinja2
Successfully installed ruamel.ordereddict-0.4.13 ruamel.yaml-0.15.94 ruamel.yaml.jinja2-0.2.2
(so-55900745) $ python
Python 2.7.15 (default, Aug 10 2018, 11:41:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ruamel.yaml import YAML
>>> yamlLoader = YAML(typ='jinja2')
>>> exit()
(so-55900745) $ deactivate
I ran into the same error message. but with python3.6.
The fix for me was to pip instead of easy_install.
Here's the easy_install related output:
(env) $ easy_install -q ruamel.yaml.jinja2
(env) $ easy_install -q ruamel.yaml
(env) $ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ruamel.yaml import YAML
>>> yamlLoader = YAML(typ='jinja2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "REDACTED/env/lib/python3.6/site-packages/ruamel.yaml-0.15.96-py3.6-linux-x86_64.egg/ruamel/yaml/main.py", line 138, in __init__
'typ "{}"not recognised (need to install plug-in?)'.format(self.typ)
NotImplementedError: typ "jinja2"not recognised (need to install plug-in?)
Here's the same thing installing with pip:
(env) $ pip -q install ruamel.yaml.jinja2
(env) $ pip -q install ruamel.yaml
(env) $ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ruamel.yaml import YAML
>>> yamlLoader = YAML(typ='jinja2')
>>> print("¯\_(ツ)_/¯")
¯\_(ツ)_/¯
If you are using a setup.py in your project, check out Can I use `pip` instead of `easy_install` for `python setup.py install` dependency resolution?
Trying to launch new django app but get error- django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
i already installed sqlite 3.27 and its in /usr/local/bin
i tried suggested procedure here- How to upgrade sqlite 3.8.2 to >= 3.8.3 but no luck
[ec2-user#ip-]$ sqlite3
SQLite version 3.27.2 2019-02-25 16:06:06
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>
but when i do python3 manage.py migrate or runserver i get
raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
I expect for django2 to take path of executable sqlite3 version that is sitting in /usr/local/bin.
Try this, it definitely works. It's working on Amazon Linux 2 AMI :
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/atomic-sqlite-sqlite-3.8.5-3.el7.art.x86_64.rpm
sudo yum localinstall atomic-sqlite-sqlite-3.8.5-3.el7.art.x86_64.rpm
sudo mv /lib64/libsqlite3.so.0.8.6{,-3.17}
sudo cp /opt/atomic/atomic-sqlite/root/usr/lib64/libsqlite3.so.0.8.6 /lib64
Check whether the version changed or not:
C:\Users\teamspirit>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.8.5'
Goal: Have python 2.7.14 and python 3.6 on my RHEL server and use pip2/pip3 to manage both.
Note: Although this server lacks an internet connection, I can download them separately and upload them to this server.
I recently installed RHEL 7.2 on a VM, this installs python 2.7.5 by default.
I decided upgrade this by doing a parallel install of 2.7.14 (using make altinstall method and keeping the existing 2.7.5 intact). Also installed python 3.6 as I plan to port all my existing python code to it in the future.
The problem arises when I try to install pip for the Python 2.7.14 or any libraries (as you will see in a little bit).
I first did a easy_install of pip:
[root#VMW01 bin]# easy_install pip
Searching for pip
Best match: pip 9.0.1
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Using /usr/local/lib/python3.6/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
This installs pip for python 2.7.5 and 3.6 but not for python 2.7.14.
Next, I downloaded the get-pip.py:
This gets installed fine for python 2.7.5 but not for python 2.7.14:
[root#VMW01 pshah]# python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 978kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 9.2MB/s
Installing collected packages: pip, wheel
Successfully installed pip-9.0.1 wheel-0.30.0
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
This seems like a lack of a SSL libray.
First, I did install this using yum:
[root#VMW01 pshah]# yum install openssl
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
[root#VMW01 pshah]# yum install openssl-devel
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
Second, this seems to be present for python 2.7.5
[root#VMW01 pshah]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
Am I overarching too much? Should I settle with the default installation of 2.7.5 and python 3.6?
I know virtualenv might be a solution here, but i'm not sure how I can make it work with Apache executing python scripts.
Thanks.
As it mentions here: https://pip.pypa.io/en/latest/installing I did a local install of pip but called the python executable for python 2.7.14.
Downloaded the .whl files for wheel, setuptools and pip and then ran the below:
[root#VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py --no-index --find-link=.
Collecting pip
Collecting setuptools
Collecting wheel
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.5.0 wheel-0.30.0
I believe calling pip2.7 will install packages for the python 2.7.14 now.
Tested this by installing the xlrd library (Note - I had the xlrd tarball in the local directory):
[root#VMW01 pshah]# pip2.7 install xlrd-1.1.0.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./xlrd-1.1.0.tar.gz
Building wheels for collected packages: xlrd
Running setup.py bdist_wheel for xlrd ... done
Stored in directory: /root/.cache/pip/wheels/b9/dc/43/e6acfa12bc48cdf3654dd7f44c66880548ea0322324bc6095f
Successfully built xlrd
Installing collected packages: xlrd
Successfully installed xlrd-1.1.0
[root#VMW01 pshah]# /usr/local/bin/python2.7
Python 2.7.14 (default, Oct 6 2017, 18:31:52)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlrd
>>>
I have installed eventlet library in python using : pip install eventlet. But when I tried to import eventlet this error occured:
$python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named eventlet
I tried to install it again but I got this :
$pip install eventlet
Requirement already satisfied (use --upgrade to upgrade): eventlet in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/eventlet-0.18.1-py3.5.egg
Requirement already satisfied (use --upgrade to upgrade): greenlet>=0.3 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/greenlet-0.4.9-py3.5-macosx-10.6-intel.egg (from eventlet)
How to rectify this error?
P.S : I am using Python 2.7
This question is not specific to Eventlet, it's just about managing multiple versions of Python on OSX.
Your pip command installed eventlet into /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5, see version.
It means you actually have two Python versions installed: 2.7 and 3.5 and pip works with 3.5.
Your options:
(recommended) use separate virtualenv [1] for every project, explicitly specify python version when creating virtualenv using virtualenv --python=python2.7 /path/to/new/venv
run python3 and use eventlet in latest Python
run pip2 install eventlet
symlink pip to pip2 ln -snf $(which pip2) $(which pip)
[1] http://docs.python-guide.org/en/latest/dev/virtualenvs/
You may also use
$py -2 -m pip install eventlet
It worked for me in Windows 10.
$pip install eventlet
This worked for me in windows10
How can Homebrew be used to install Django? How can Homebrew be used to install tools like setup-tools in python? What all packages can be installed using Homebrew?
Homebrew doesn't package Django. You should install Django using Python's package manager, pip:
$ pip install Django
Using pip to install Django is very convenient and should only take a few seconds using the instructions below. However, be careful you use the correct pip depending on whether installing on an older version of Python (2.7 or lower), or Python 3+. You may have python & python3 installed, and therefore wish to distinguish between pip and pip3.
For instance, locally I have:
$ pip --version
pip 1.2.1 from /Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg (python 2.7)
$ pip3 --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)
Depending on which version you are installing to:
$ pip install Django
or
$ pip3 install Django
To test the install was successful (here I installed with pip3, hence running python3 command):
$ python3
Python 3.4.2 (default, Jan 19 2015, 22:35:23)
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.8.6
>>>
That's it!