I am trying to install upstox, which is a Python API for connecting to market data. I am unable to install it on Python3.5.
My config is
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32. And the error I keep getting is:
Collecting upstox
Using cached upstox-0.7-py2.py3-none-any.whl
Collecting future (from upstox)
Using cached future-0.16.0.tar.gz
Collecting websocket-client (from upstox)
Using cached websocket_client-0.42.1-py2.py3-none-any.whl
Collecting pycurl (from upstox)
Using cached pycurl-7.43.0-cp35-none-win32.whl
Collecting enum (from upstox)
Using cached enum-0.4.6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\setuptools\__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\setuptools\extern\__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pkg_resources\__init__.py", line 33, in <module>
import platform
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\platform.py", line 117, in <module>
import sys, os, re, subprocess
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 50, in <module>
import signal
File "C:\Users\UserPad\AppData\Local\Programs\Python\Python35-32\lib\signal.py", line 4, in <module>
from enum import IntEnum as _IntEnum
ImportError: cannot import name 'IntEnum'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\UserPad\AppData\Local\Temp\pycharm-packaging\enum\
for python2
sudo pip2 install -U enum
for python3
sudo pip3 install -U enum34
pip install enum34
will solve the issue
i named file as enum.py and recive that result
rename and all
for python2, we need both enum and enum34
pip install enum
pip install enum34
Have you installed enum before installing your desired package? It looks like it wants you to install it first.
Run this command in CMD to install enum, and then try installing your desired package:
pip install enum
Related
If I create a clean virtualenv, upgrade my pip version to 9.0.1 (most recent), and try:
$ pip install asteval
Collecting asteval
Downloading asteval-0.9.10.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-nnWnaR/asteval/setup.py", line 3, in <module>
import asteval
File "asteval/__init__.py", line 20, in <module>
from .asteval import Interpreter
File "asteval/asteval.py", line 18, in <module>
import six
ImportError: No module named six
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-nnWnaR/asteval/
Maybe I'm missing something, I thought pip should handle the dependencies? I thought it used to.
The bypass is to separately pip install six, then asteval will install. But I want to require asteval as an import requirement in my code, and I don't want to have to trace dependencies it might have and list those as requirements.
asteval is making a common mistake: importing itself into its setup.py. You should file a bug against the project, asking them to stop doing that.
I am trying to run this Matplotlib example using Python 3. To run this I needed to install gi first (I am using pyenv):
$ python --version
Python 3.6.1
$ pip --version
pip 9.0.1 from /home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages (python 3.6)
$ pip install gi
Collecting gi
Downloading gi-1.2.tar.gz
Collecting requests (from gi)
Downloading requests-2.16.0-py2.py3-none-any.whl (85kB)
100% |████████████████████████████████| 92kB 959kB/s
Collecting idna<2.6,>=2.5 (from requests->gi)
Downloading idna-2.5-py2.py3-none-any.whl (55kB)
100% |████████████████████████████████| 61kB 1.2MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests->gi)
Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 1.8MB/s
Collecting urllib3<1.22,>=1.21.1 (from requests->gi)
Downloading urllib3-1.21.1-py2.py3-none-any.whl (131kB)
100% |████████████████████████████████| 133kB 1.8MB/s
Collecting certifi>=2017.4.17 (from requests->gi)
Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
100% |████████████████████████████████| 378kB 284kB/s
Installing collected packages: idna, chardet, urllib3, certifi, requests, gi
Running setup.py install for gi ... done
Successfully installed certifi-2017.4.17 chardet-3.0.3 gi-1.2 idna-2.5 requests-2.16.0 urllib3-1.21.1
Now, running the example:
$ python toolmanager.py
Traceback (most recent call last):
File "./toolmanager.py", line 8, in <module>
import matplotlib.pyplot as plt
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 6, in <module>
from . import backend_gtk3
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3.py", line 10, in <module>
import gi
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/gi/__init__.py", line 39
print url
^
SyntaxError: Missing parentheses in call to 'print'
Seems like pip somehow installed a Python 2 version? How can I fix this?
First, pip install gi will install another unrelated package, the correct
name is pgi. But after running:
$ pip uninstall gi
$ pip install pgi
$ python toolmanager.py
[...]
Traceback (most recent call last):
File "toolmanager.py", line 14, in <module>
import matplotlib.pyplot as plt
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 6, in <module>
from . import backend_gtk3
File "/home/hakon/.pyenv/versions/3.6.1/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3.py", line 12, in <module>
raise ImportError("Gtk3 backend requires pygobject to be installed.")
ImportError: Gtk3 backend requires pygobject to be installed.
It seems that pygobject for Python 3 cannot be installed from PyPI. So I tried to install everything from the Ubuntu distribution package python3-gi instead:
$ sudo apt-get install python3-gi
$ pyenv local system
$ python3 --version
Python 3.5.3
$ python3 toolmanager.py
and this works fine :)
The chosen answer is a little bit outdated as of now:
Last update of pgi in 2018
Since 2018, PyGObject is available for python3 from PyPI.
Installing the relevant package, plus its dependencies, depending on your environment, is still possible, just follow the steps from the doc.
But if you work from a venv, you might still stumble upon a ModuleNotFoundError: No module named 'gi' when importing gi. The venv ignores the system-wide module. Then simply run, from your venv: pip install PyGObject (or use poetry or your favorite python packages manager). Of course, you still need to have installed PyGObject's dependencies (see the link to the doc, right above).
To install for the standard python, Håkon Hægland answer is the best choice.
But for an alternate python version,
one can use pip<version>.
Beware that the alternate pip has to be used to match the alternate python.
The full explanations are given in the documentation.
For instance on openSUSE (standard python version 3.6, alternate installed 3.8):
> sudo zypper install cairo-devel pkg-config python3-devel gcc gobject-introspection-devel
> pip3.8 install --user pycairo
> pip3.8 install --user PyGObject
> python3.8
Python 3.8.1 (default, Feb 1 2020, 14:50:41)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>
This has me pretty confused. I've installed pyad using pip and everything seems fine:
C:\WINDOWS\system32>pip install pyad
Collecting pyad
Using cached pyad-0.5.16.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python35\lib\site-packages (from pyad)
Requirement already satisfied (use --upgrade to upgrade): pywin32 in c:\python35\lib\site-packages (from pyad)
Installing collected packages: pyad
Running setup.py install for pyad ... done
Successfully installed pyad-0.5.16
But when I try to use it, I get an error that complains about not finding adbase:
C:\WINDOWS\system32>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyad import aduser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'
>>> import pyad
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'
This is odd, because if I try to uninstall pyad or if I check the site-packages directory, adbase is definitely there:
C:\WINDOWS\system32>pip uninstall pyad
Uninstalling pyad-0.5.16:
c:\python35\lib\site-packages\pyad-0.5.16-py3.5.egg-info
c:\python35\lib\site-packages\pyad\__init__.py
c:\python35\lib\site-packages\pyad\__pycache__\__init__.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adcomputer.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\addomain.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adgroup.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adquery.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adsearch.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\pyad.cpython-35.pyc
c:\python35\lib\site-packages\pyad\adbase.py
c:\python35\lib\site-packages\pyad\adcomputer.py
c:\python35\lib\site-packages\pyad\adcontainer.py
c:\python35\lib\site-packages\pyad\addomain.py
c:\python35\lib\site-packages\pyad\adgroup.py
c:\python35\lib\site-packages\pyad\adobject.py
c:\python35\lib\site-packages\pyad\adquery.py
c:\python35\lib\site-packages\pyad\adsearch.py
c:\python35\lib\site-packages\pyad\aduser.py
c:\python35\lib\site-packages\pyad\pyad.py
c:\python35\lib\site-packages\pyad\pyadconstants.py
c:\python35\lib\site-packages\pyad\pyadexceptions.py
c:\python35\lib\site-packages\pyad\pyadutils.py
Proceed (y/n)?
pyad directory contents
I'm really not sure what else to try. I've run everything under an elevated command prompt, so it's not a permissions issue. I even tried downloading pyad and installing it using setup.py, but I had the same problem with that. adbase is definitely there, and I can't figure out why Python isn't finding it.
That's a bug on pyad part. They're importing adbase as if it were a standalone module or package, and that's why it does not work. The proper way to fix this would be to change the import to an absolute import from pyad.adbase import ... or relative from .adbase import ....
However, if you check the master branch on Github, you will see that they have actually fixed it. But that's not all, if you check their setup.py you'll see that the version on Github is 0.5.15, while the last version on PyPI, which is the one you have installed, is 0.5.16. Weird.
I suggest you to install the package directly from Github, and that should take care of the problem. To do that, first uninstall pyad and then run
pip install https://github.com/zakird/pyad/archive/master.zip
I have python 3.5 and 2.7 installed (I don't know if this might be the problem) and I need to use ZeroC Ice and when I do:
sudo pip install ice
I get the following error in the terminal:
Collecting ice
Using cached ice-0.0.1.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-MoRI5C/ice/setup.py", line 32, in <module>
import ice
File "ice.py", line 46, in <module>
import urllib.parse
ImportError: No module named parse
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-MoRI5C/ice/
But parse is already installed (I guess):
sudo -H pip install parse
Requirement already satisfied (use --upgrade to upgrade): parse in /usr/local/lib/python2.7/dist-packages
How can I solve this please?
THanks
This is a simple mistake, try this instead.
pip install zeroc-ice
This should do the correct job.
I am trying to run a python script which is seems to be dependent on a module called straight.plugin, which it fails to recognise.
(antismash)[username#glenn antismash]$ python run_antismash.py
Traceback (most recent call last):
File "run_antismash.py", line 32, in <module>
import straight.plugin
File "/c3se/users/username/Glenn/virtualenvs/antismash/lib/python2.7/site-packages/straight/plugin/__init__.py", line 1, in <module>
from straight.plugin import loaders
File "/c3se/users/username/Glenn/virtualenvs/antismash/lib/python2.7/site-packages/straight/plugin/loaders.py", line 9, in <module>
from straight.plugin.manager import PluginManager
ImportError: No module named manager
When I try to install straight.plugin python tells me that it is already installed.
(antismash)[username#glenn antismash]$ pip instal
l straight.plugin
Requirement already satisfied (use --upgrade to upgrade): straight.plugin in /c3se/users/username/Glenn/virtualenvs/antismash/lib/python2.7/site-packages
Cleaning up...
Can somebody help me on what to do to run this python script?
I am running Python 2.7.6 on Linux distribution CentOS 6.6
Looks like the manager module isnt in the PyPI Package and is a known issue https://github.com/ironfroggy/straight.plugin/issues/17
Installing this version:
pip install straight.plugin==1.4.0-post-1
solves the problem for me:
In [1]: from straight.plugin.manager import PluginManager
In [2]: