I have recently just started the foray into running cygwin on windows.
Attempting to setup a development environment, and noticing some oddities.
so for example, I have installed virtualenvwrapper but when i open a new cygwin terminal i get (after setting appropriate lines in my .bashrc)
-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
so i attempt to reinstall virtualenvwrapper using pip and i get
$ pip install virtualenvwrapper
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in c:\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): virtualenv in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): stevedore in c:\python27\lib\site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): argparse in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pbr!=0.7,<1.0,>=0.6 in c:\python27\lib\site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pip in c:\python27\lib\site-packages (from pbr!=0.7,<1.0,>=0.6->stevedore->virtualenvwrapper)
What gives? why is it installing it to the windows directory? sure enough i can see virtualenvwrapper is not installed in c:/cygwin64/lib/Python2.7/site-packages/
in fact that directory is completely bare.
I expected to see the updated version of pip i installed. it's of course in the windows directory.
I had previously installed virtualenvwrapper via pip on windows, but my understanding is that the windows environment and the cygwin terminal are totally seperate and shouldn't know about each other(?)
as you might expect this is also wrecking havoc with other packages.
for example attempting to install uwsgi i get this error:
Collecting uWSGI==2.0.7 (from -r _pip/requirements.txt (line 52))
Downloading uwsgi-2.0.7.tar.gz (772kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "c:\cygwin64\tmp\pip-build-n5cvur\uWSGI\setup.py", line 3, in <module>
import uwsgiconfig as uc
File "uwsgiconfig.py", line 8, in <module>
uwsgi_os = os.uname()[0]
AttributeError: 'module' object has no attribute 'uname'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\cygwin64\tmp\pip-build-n5cvur\uWSGI
which i understand is because os.uname doesn't exist on windows. Why is the pip installer running setup using windows python?
------- update -------
I think i found the root cause
$ which pip
/c/Python27/Scripts/pip
so my questions are:
why is pip the windows one by default? or how did this happen?
-------- Update 2 ----------
i just discovered that the default PATH env variable in cygwin appends the windows one. sure enough the path to the windows pip is there.
$ echo $PATH
Is this expected? if so, why is this desireable? doesn't it increase the chance of unintentional conflicts like this one?
So I'll just leave this here as a warning to n00bs like myself.
cygwin appends the windows path to the cygwin terminal PATH env variable.
if you already have pip installed on windows and it is on your path it will work but with unexpected results like above.
to check make sure you do
which python
which pip
to confirm what version you are running.
only python 2.7.9 and up include pip by default and the package included in cygwin isn't there yet. so you will most likely need to install pip manually
if you had a cygwin terminal open, you will need to close all windows otherwise it remembers the path to the windows pip.
See this answer to setup easy_install in cygwin's python install.
https://serverfault.com/questions/7282/how-to-run-easy-install-in-cygwin
Once that is done, you can use easy_install to get pip.
Related
A python newbie question:
On an Ubuntu system, I installed a python package using sudo pip install. (The package is called hlmm)
I'm using the miniconda3 environment and the only environment variable specified in my .bashrc is:
export PATH="/home/<my_username>/miniconda3/bin:$PATH"
Now I want to run a test script from the package I installed, which is located under a tests folder relative to where that package was installed.
I used pip list | xargs -exec pip show to look for the location of that package but it doesn't show up.
I also tried in python to import the package, using:
import hlmm
And I'm getting:
>>> import hlmm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'hlmm'
If I redo sudo pip install hlmm I get:
Requirement already satisfied: hlmm in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pysnptools in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pandas>=0.19.0 in /usr/local/lib/python2.7/dist-packages (from pysnptools->hlmm)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/dist-packages (from python-dateutil>=2.5.0->pandas>=0.19.0->pysnptools->hlmm)
And, I do see the hlmm folder under /usr/local/lib/python2.7/dist-packages, but cannot find that tests folder:
ls -1 /usr/local/lib/python2.7/dist-packages/hlmm
__init__.py
__init__.pyc
hetlm.py
hetlm.pyc
hetlmm.py
hetlmm.pyc
How do I find its location? And, is the package really successfully installed despite the import hlmm error?
This was getting too long to be a comment, so I'm posting it as an answer.
Yeah, it sounds like pip installed it from your python 2.7 version. You should read this post: How to install PyPi packages using anacaonda conda command and this article: https://www.anaconda.com/using-pip-in-a-conda-environment/ to decide how you want to proceed. I generally use conda when possible, and pip if conda doesn't have a build. You might want to run pip uninstall hlmm then activate your conda env and use pip3 install hlmm. But, I think you should decide the best way to manage your environments after doing research.
I'm new to Windows and using the command line. I'm having issues with how the path works.
I installed Python 3 using Anaconda on a Windows 10, and I'm using a virtual environment that doesn't seem to recognize python.
$ python --version
bash: python: command not found
In the command line, Python is installed, but many packages like Flask and Pandas also aren't being recognized. I've used pip install, which works correctly
$ pip install flask
Requirement already satisfied: flask in c:\users\dta\anaconda3\lib\site-packages (1.0.2)
Requirement already satisfied: click>=5.1 in c:\users\dta\anaconda3\lib\site-packages (from flask) (6.7)
Requirement already satisfied: itsdangerous>=0.24 in c:\users\dta\anaconda3\lib\site-packages (from flask) (0.24)
Requirement already satisfied: Werkzeug>=0.14 in c:\users\dta\anaconda3\lib\site-packages (from flask) (0.14.1)
Requirement already satisfied: Jinja2>=2.10 in c:\users\dta\anaconda3\lib\site-packages (from flask) (2.10)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\dta\anaconda3\lib\site-packages (from Jinja2>=2.10->flask) (1.0)
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
But then running a program with either of those packages doesn't work and I get a result like this one:
Traceback (most recent call last):
File "app.py", line 1, in <module>
import flask
ModuleNotFoundError: No module named 'flask'
It seems like the path is set, but there's some issue with the command line recognizing it correctly. I've uninstalled and then reinstalled Python and made sure to check the box ‘Add Python to PATH’ during the installation but nothing has worked. Any ideas on how to fix this?
You most likely do not have Anaconda on your Path. Try:
echo %PATH%
if [Mini|Ana]conda is not there, open Anaconda CMD. Start typing on wundows Start Menu. In that, conda command should work. Type where conda. It show where conda is: then do something like
SETX PATH “%PATH%;%USERPROFILE%\Anaconda3\Scripts;%USERPROFILE%\Anaconda3”
This will set anaconda to Path. Close and Restart CMD
If you have different environments, try
conda env list
To activate your environment:
conda activate environmentName
Remember to use conda install ... over pip as it deals with upgrades and downgrade for compatibility issues.
if Anaconda is there, then you must have another Python their too that comes before Anaconda. That will be selected over Anaconda, unless you rearrange that Anaconda comes first before it.
If you do not want that, you can simply create an environment:
conda create -n awesome python=3.7
Then activate it and install your packages there:
conda activate awesome
conda install flask
python -V # Python 3.7
To see where Python looks for packages do:
python -c "import sys;print(sys.path)"
See where it is looking for packages.
Python Version 2.7
On windows 10 64bits
pip install <whatever>
command not working.
C:\new_software\Python27\Scripts>python -m ensurepip
Requirement already satisfied: setuptools in c:\new_software\python27\lib\site-packages\setuptools-28.8.0-py2.7.egg
Requirement already satisfied: pip in c:\new_software\python27\lib\site-packages\pip-9.0.1-py2.7.egg
C:\new_software\Python27\Scripts>python -m ensurepip --upgrade
Requirement already up-to-date: setuptools in c:\new_software\python27\lib\site-packages\setuptools-28.8.0-py2.7.egg
Requirement already up-to-date: pip in c:\new_software\python27\lib\site-packages\pip-9.0.1-py2.7.egg
C:\new_software\Python27\Scripts>pip install wheel
failed to create process.
C:\new_software\Python27\Scripts>python -m install pip install pip
C:\new_software\Python27\python.exe: No module named install
I have python 3.x and 2.7; in 3.x pip works fine; only in 2.7 it aint.
Based on reading articles online: I have completed:
1.environment variable set up.
2.python VC++ installed
Thank you all for your response. I read the link shared by #cricket_007.
Solution:
Update all .py files [firstline] inside /Scripts folder with current path of Python Home. You will notice it will be pointing to an older location.
Then try running pip command from new CMD prompt, should work fine.
I noticed a strange phenomenon related to dist-packages paths. The order of my paths in my system-wide installation of python 3 (simply running python3 and then printing sys.path) is as follows:
/usr/local/lib/python3.4/dist-packages
/usr/lib/python3/dist-packages
i.e. the path in local is preferred. However, creating a virtual environment and running python3 after activating the environment gives:
/usr/lib/python3/dist-packages
/usr/local/lib/python3.4/dist-packages
The order is clearly reversed. Yet, pip still searches local first, which results in a different version of a library seen by pip dependencies and a different one used when importing.
Can someone explain the discrepancy?
EDIT:
When the virtualenv is activated, the pip used is the one installed in the virtualenv:
pip 9.0.1 from ~/.virtualenv/python3/lib/python3.4/site-packages (python 3.4)
and yet, despite the path pointing first to dist-utils in /usr/lib, it does resolve dependencies with what's in /usr/local/lib:
pip3 install --upgrade setuptools
Requirement already up-to-date: setuptools in ./.virtualenv/python3/lib/python3.4/site-packages
Requirement already up-to-date: appdirs>=1.4.0 in ./.virtualenv/python3/lib/python3.4/site-packages (from setuptools)
Requirement already up-to-date: packaging>=16.8 in /usr/local/lib/python3.4/dist-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in ./.virtualenv/python3/lib/python3.4/site-packages (from setuptools)
Requirement already up-to-date: pyparsing in /usr/local/lib/python3.4/dist-packages (from packaging>=16.8->setuptools)
I just completed the installation of the dcos environment in the lab environment, and when I try to install the dcos client in on centos7 linux machine I got
**[root#rmavmdock5 dcos]# bash install.sh . http://10.120.1.187**
Installing DC/OS CLI from PyPI...
New python executable in /root/dcos/bin/python
Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/root/dcos/bin/dcos", line 7, in <module>
from dcoscli.main import main
File "/root/dcos/lib/python2.7/site-packages/dcoscli/main.py", line 7, in <module>
from dcos import config, constants, emitting, errors, http, subcommand, util
File "/root/dcos/lib/python2.7/site-packages/dcos/config.py", line 10, in <module>
from dcos import constants, jsonitem, subcommand, util
File "/root/dcos/lib/python2.7/site-packages/dcos/jsonitem.py", line 5, in <module>
from dcos import util
File "/root/dcos/lib/python2.7/site-packages/dcos/util.py", line 2, in <module>
import concurrent.futures
ImportError: No module named concurrent.futures
I looked into google and find our similar case fixed running 'pip install futures' but even after install this the installation keeps failing
[root#rmavmdock5 bin]# pip install features
Requirement already satisfied (use --upgrade to upgrade): features in /usr/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): concepts<1.0,>=0.7 in /usr/lib/python2.7/site-packages (from features)
Requirement already satisfied (use --upgrade to upgrade): graphviz<1.0,>=0.3 in /usr/lib/python2.7/site-packages (from features)
Requirement already satisfied (use --upgrade to upgrade): fileconfig<1.0,>=0.5 in /usr/lib/python2.7/site-packages (from features)
Requirement already satisfied (use --upgrade to upgrade): bitsets<1.0,>=0.7 in /usr/lib/python2.7/site-packages (from concepts<1.0,>=0.7->features)
[root#rmavmdock5 bin]# pip install --upgrade features
Requirement already up-to-date: features in /usr/lib/python2.7/site-packages
Requirement already up-to-date: concepts<1.0,>=0.7 in /usr/lib/python2.7/site-packages (from features)
Requirement already up-to-date: graphviz<1.0,>=0.3 in /usr/lib/python2.7/site-packages (from features)
Requirement already up-to-date: fileconfig<1.0,>=0.5 in /usr/lib/python2.7/site-packages (from features)
Requirement already up-to-date: bitsets<1.0,>=0.7 in /usr/lib/python2.7/site-packages (from concepts<1.0,>=0.7->features)
pip version
[root#rmavmdock5 bin]# pip -V
pip 8.1.2 from /root/dcos/lib/python2.7/site-packages (python 2.7)
Checking the install script line by line i found that the dcos client installation process reported those errors when the install script tries to run
# storage dcos config set core.reporting true
but the whole process is working fine untill the dcos binary is configure with command
/root/dcos/bin/pip install --quiet dcoscli
, this command is the one that makes the dcos command available and seems that for any reason is not working properly
I've run the same command with the -v option (output is huge and don't know how to attach files), but the command ends
Successfully installed dcos-0.4.8 dcoscli-0.4.8 docopt-0.6.2 gitdb-0.6.4 gitpython-1.0.2 jsonschema-2.4.0 pager-3.3 pkginfo-1.2.1 portalocker-0.5.7 prettytable-0.7.2 pygments-2.1.3 pypng-0.0.18 pystache-0.5.4 requests-2.10.0 rollbar-0.13.2 six-1.10.0 smmap-0.9.0 toml-0.9.1 virtualenv-13.1.2
Cleaning up..
the virtualenv env doesn't have futures. install via the virtual env pip, not the system one.
from the dcos dir:
bin/pip install futures
then do your bash install.sh . <url> again