I have python 3.2 on my pc and i want to be able to run the following:
'pip install requests' and 'pip install selenium'.
To do this i know i need to install pip from here -> https://pip.pypa.io/en/stable/installing/
But when I click on the file python comes up and closes again right away and pip is not installed.
I tried running it through IDLE and get the following:
> Traceback (most recent call last):
File "C:\Users\Jarratt\Desktop\get-pip.py", line 17759, in <module>
main()
File "C:\Users\Jarratt\Desktop\get-pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "C:\Users\Jarratt\Desktop\get-pip.py", line 110, in bootstrap
import setuptools # noqa
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\extension.py", line 8, in <module>
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\dist.py", line 19, in <module>
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\pkg_resources\__init__.py", line 106, in <module>
warnings.warn(msg)
File "C:\Python32\lib\idlelib\PyShell.py", line 59, in idle_showwarning
file.write(warnings.formatwarning(message, category, filename,
AttributeError: 'NoneType' object has no attribute 'write'
>>>
You need to run it from the command line:
Download https://bootstrap.pypa.io/get-pip.py save somewhere so that you could find it like "C:\".
Open "Start Menu" and in execute type "cmd" and [Enter], or search for "Standard" folder in "Start Menu" and open "Command line" there.
In command line type and execute "python C:\get-pip.py" or "python3 C:\get-pip.py".
Usually works fine this way.
Looks like you are new to python, But pip.exe is a command
and you have to run it from command line, or with run, or by manually clicking on it's icon. You can use this code if you want to:
>>> import os
>>> os.system("pip")
Related
I was trying to update python's pip command through the command line and accidentally pressed ctrl+c which cancelled the upgrade mid-process.
As soon as I realised what had happened I tried to rerun the command python -m install --upgrade pip and I got this error code:
(Currently running python 3.8.3) on Windows 10 Home
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 21, in <module>
from pip._vendor.packaging.utils import canonicalize_name
ModuleNotFoundError: No module named 'pip._vendor'
Is there any way to fix this or should I reinstall python? I had no extra pip libraries installed except the requests library.
You can follow this guide. I also describe the steps here:
Find where your python is located. In Windows it might be located in a path similar to C:\Users\<your-name>\AppsData\Local\Programs\Python\Python38-<minor-version>
Download the get-pip.py script to the directory where your Python is located. You can just copy the content and paste it into a file with the same name
Open the terminal (or PowerShell) and change the directory to where your Python is located.
run the script as follows: python get-pip.py
Verify the installation by executing: pip -V
I have coded a mathematical model and want to solve it using DOCPLEX module. My interpreter is Python 3.7. However, after doing a lot of effort, I will face the following error:
Traceback (most recent call last):
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 290, in get_cplex_module
import cplex ##UnresolvedImport
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\__init__.py", line 44, in <module>
from .aborter import Aborter
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\aborter.py", line 13, in <module>
from ._internal import _procedural as _proc
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\_internal\__init__.py", line 20, in <module>
from . import _list_array_utils
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\_internal\_list_array_utils.py", line 14, in <module>
from . import _pycplex as CPX
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\_internal\_pycplex.py", line 13, in <module>
from . import _pycplex_platform
File "C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.8\x64_win64\cplex\_internal\_pycplex_platform.py", line 22, in <module>
from cplex._internal.py37_cplex2010 import *
ModuleNotFoundError: No module named 'cplex._internal.py37_cplex2010'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/xxx/PycharmProjects/pythonProject/EPC _LTC.py", line 11, in <module>
mdl = Model("LTC")
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\model.py", line 398, in __init__
self._environment = self._make_environment()
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\model.py", line 174, in _make_environment
env = Environment.get_default_env()
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 427, in get_default_env
Environment._default_env = Environment.make_new_configured_env()
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 422, in make_new_configured_env
return Environment(start_auto_configure=True)
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 84, in __init__
self.auto_configure(logger=logger)
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 220, in auto_configure
self.check_cplex(logger=logger)
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 328, in check_cplex
cplex = self.get_cplex_module(logger=logger)
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 314, in get_cplex_module
cplex = load_cplex_from_cos_root(loc) if loc else None
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 286, in load_cplex_from_cos_root
return load_cplex(full_path, version=version)
File "C:\Users\xxx\PycharmProjects\pythonProject\venv\lib\site-packages\docplex\mp\environment.py", line 261, in load_cplex
raise FileNotFoundError("Could not load module from %s" % module_location)
FileNotFoundError: Could not load module from C:\Program Files\IBM\ILOG\CPLEX_Studio201;C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.7\x64_win64;C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python\3.7\x64_win64\cplex;\cplex\python\3.7\x64_win64\cplex\__init__.py
I have already run the following codes in my Pycharm's terminal:
cd C:\Program Files\IBM\ILOG\CPLEX_Studio201\python
python setup.py install
or
cd C:\Program Files\IBM\ILOG\CPLEX_Studio201\python
python setup.py install --home C:\Users\xxx\PycharmProjects\pythonProject\venv\Lib\site-packages\cplex
Finally, I also set the path variables of my own username to something like below:
"C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\python\3.6\x64_win64" and
"C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\bin\x64_win64\cplex.exe"
In my case I upgraded to python 3.8 and solved the issue
or you can use this:
pip install docplex==2.15.194
The problem is that python setup.py install does not guaranty that the python interpreter you are using is the same as your virtual env.
You need to activate your env before you run the install script.
Please open a Terminal then run:
C:\Users\xxx\PycharmProjects\pythonProject\venv\Scripts\activate
Then you can
cd C:\Program Files\IBM\ILOG\CPLEX_Studio201\cplex\python
pip install .
Docplex has a check_list.py script, which helps diagnose presence and location of cplex versions. In a terminal where Python is present, type
$ python -m docplex.mp.check_list
The answer looks like:
* system is: Windows 64bit
* Python version 3.7.8, located at: C:\python\anaconda2020.02\envs\docplex37\python.exe
* docplex is present, version is 2.20.204
* CPLEX library is present, version is 12.10.0.0, located at: C:\OPTIM\cplex_distrib\cplex1210R0\python\3.7\x64_win64
* pandas is present, version is 1.1.4
From the check list output you posted, I can see that you installed cos201.
Docplex need the Python/Cplex interface located inside cos, in your case:
C:/Program Files/IBM/ILOG/CPLEX_Studio201/cplex/python/3.7/x64_win64
This path should be added as a content root in your Pycharm project (File/Settings/Project Structure -> add content root
To check this, open a Python console tab in Pycharm, and try
import cplex
Once you add the right path , this should work.
You can then run the check list from within the console:
from docplex.mp.check_list import run_docplex_check_list
run_docplex_check_list()
Once this works, your program should solve OK inside Pycharm.
This said, I see your version of docplex is 2.15, which is older than CPLEX 20.1. You should update DOcplex to the latest version, which is compatible with CPLEX 20.1.
all,
I've installed the package:pywinauto successfully with "pip install pywinauto", but it always fails, why?
I did it in this way:
pip install pywinauto
and then under the windows cmd env, I run the python:
and then:
import pywinauto
I got the following errors:
....
>>> import pywinauto
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pywinauto\__init__.py", line 40, in <module>
from . import findwindows
File "C:\Python27\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Python27\lib\site-packages\pywinauto\controls\__init__.py", line 36,in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "C:\Python27\lib\site-packages\pywinauto\controls\uiawrapper.py", line 44, in <module>
from ..uia_defines import IUIA
File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 175, in <module>
pattern_ids = _build_pattern_ids_dic()
File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 163, in _build_pattern_ids_dic
if hasattr(IUIA().ui_automation_client, cls_name):
File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 50, in __call__
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 60, in __init__
self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
File "C:\Python27\lib\site-packages\comtypes\client\_generate.py", line 97, in GetModule
tlib = comtypes.typeinfo.LoadTypeLibEx(tlib)
File "C:\Python27\lib\site-packages\comtypes\typeinfo.py", line 485, in LoadTypeLibEx
_oleaut32.LoadTypeLibEx(c_wchar_p(szFile), regkind, byref(ptl))
File "_ctypes/callproc.c", line 950, in GetResult
WindowsError: [Error -2147312566] Error loading type library/DLL
It looks like you're using old OS Windows version like Windows XP. MS UI Automation is included into Windows Vista and later. But you may install .NET Framework 3.0+ to get UIAutomationCore.dll available even on Windows XP. If you don't need MS UI Automation technology at all, just run pip uninstall comtypes and pywinauto will work with Win32 API only.
If installing .NET Framework 3.0+ doesn't help (or if it's already installed) and you need to use Win XP, install Windows update KB971513. It solved the loading library issue for me.
I need upgrade the Winxp to Win7 or Win8, or Win10.
I'm attempting to install pip for arcpy (arcgis 10.2 on windows 7). Running get-pip.py results in the following error message:
X:\python>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\temp\tmpou5fje\pip.zip\pip\__init__.py", line 26, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\utils\__init__.py", line 27, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\pkg_resources\__init__.py", line 73, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 275, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 373, in Specifier
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Using an administrator command prompt doesn't help. My real goal is to get win32com working under arcpy. I usual just copy the appropriate directories out of c:\python27\lib\site-packages to c:\python27\arcgis10.2\lib\site-packages to install a package under arcpy (why doesn't arcpy come with pip?) but that's not working for win32com, presumably do to a missing dll or other windows specific file.
I would recommend the following:
Get the setuptools module
Get the pip module`
And then run the following in command line (assuming windows)
path-to-python path-to-setuptools install
path-to-python path-to-pip install
I work on a closed network (away from the interwebs of old) and cannot use get-pip.py so I find it best to simply download the actual modules and hard install.
Keep us posted!
Copy get_pip.py to "C:\Python27\ArcGIS10.2", then perform command "python get-pip.py" in the directory.
Note that keep network connected in the process, so that auto-download and setup setuptools,wheels,etc.
Hope that can help you.
Try opening a CMD prompt and typing:
C:\Python27\ArcGIS10.2\python.exe -m pip install -U pip
I am trying to run PyCallgraph module on my application. My application runs on Mac and I am running the application from PyCharm
Here is what I have tried
def main(url):
from pycallgraph import PyCallGraph
from pycallgraph.output import GephiOutput, GraphvizOutput
graphviz = GraphvizOutput()
with PyCallGraph(output=graphviz):
obj = MyApp("agr1")
obj.extract('372','100001' , '999')
I am getting the following error ...
libpath/shortest.c:324: triangulation failed
libpath/shortest.c:192: source point not in any triangle
Error: in routesplines, Pshortestpath failed
Traceback (most recent call last):
File "/Users/anurag/Work/quad-projects/quad-hge/src/main/python/extractor/hgextractor.py", line 63, in <module>
main(url)
File "/Users/anurag/Work/quad-projects/quad-hge/src/main/python/extractor/hgextractor.py", line 51, in main
hge.extract('372','100001' , '999', url_list)
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 38, in __exit__
self.done()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 81, in done
self.stop()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 90, in generate
output.done()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/output/graphviz.py", line 112, in done
'code %(ret)i.' % locals())
pycallgraph.exceptions.PyCallGraphException: The command "dot -Tpng -opycallgraph.png /var/folders/00/z1t7sw2x1ml1ydhgp084c1xh0000gn/T/tmphl_rNH" failed with error code 11.
Process finished with exit code 1
I even tried installing graphviz on my Mac using brew install graphviz
and setting $PATH variable on my PyCharm editor as described here pycallgraph with pycharm does not work
I don't know the exact root cause for this and I am stuck at this for last 2-3 days.