ZacharyST
ZacharyST

Reputation: 676

Confusion Regarding pip and conda environment

I am trying to install the twint library into a conda virtual environment. I have to use pip because the library is not at the conda or conda forge channels. twint requires Python 3.6, so I created a new virtual environment with that version. I created that environment following Anaconda's instructions:

conda create --name py36 python=3.6

Again following Anaconda's instructions, I install pip to that environment. A weird thing, I believe, happens here, which is that I am told pip is already installed.

MacBook-Pro-89:~ Zack$ conda install -n py36 pip
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata .........
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /Users/Zack/anaconda/envs/py36:
#
pip                       20.0.2                     py_2    conda-forge

Whether I check my pip version (which -a pip) from the py36 environment or not, I am shown the following:

(py36) MacBook-Pro-89:~ Zack$ which -a pip
/Users/Zack/anaconda/bin/pip
/Users/Zack/anaconda/bin/pip
/Users/Zack/anaconda/bin/pip
/Users/Zack/anaconda/bin/pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip

If I try to install twint, it errors out at multidict. The error message is very long, so below I show the top and bottom, which shows something about Python 3.5.

     ERROR: Command errored out with exit status 1:
       command: /Users/Zack/anaconda/bin/python /Users/Zack/anaconda/lib/python3.5/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/56/sdxbs4_x1xlgyb_9vg9mkn300000gn/T/pip-build-env-exnpi3i_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'pip>=18' 'setuptools>=40' wheel
           cwd: None
[DELETED BY ME FOR THIS ANSWER]
    ERROR: Command errored out with exit status 1: /Users/Zack/anaconda/bin/python /Users/Zack/anaconda/lib/python3.5/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/56/sdxbs4_x1xlgyb_9vg9mkn300000gn/T/pip-build-env-exnpi3i_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'pip>=18' 'setuptools>=40' wheel Check the logs for full command output.

I have tried with pip3 as well, same error.

I have also tried cloning the twint project from github and installing using the requirements file, but I get a similar error to what I'm seeing already:

ERROR: Package 'twint' requires a different Python: 3.5.2 not in '>=3.6.0'

I do not think it is a PYTHONPATH issue, as I don't believe I ever set it.

MacBook-Pro-89:~ Zack$ echo $PYTHONPATH

MacBook-Pro-89:~ Zack$ source activate py36
(py36) MacBook-Pro-89:~ Zack$ echo $PYTHONPATH

(py36) MacBook-Pro-89:~ Zack$ 

I am pretty sure that I do not have pip in the py36 environment I created, which somehow means it tries using Python 3.5. What I don't understand is that I do have pip in a py35 environment I created. I also do not have this problem on a remote desktop I use, where again pip does exist in the Python 3.6 environment. So there is something funky going on with my py36 environment on my laptop.

Based on the helpful comments below, I have tried the following but also to no avail. See the comments for my responses.

install -y python=3.6 pip conda which pip /Users/Zack/anaconda/bin/pip

python -m pip twint /Users/Zack/anaconda/envs/py36/bin/python: No module named pip

I am using a 2016 Macbook Pro with OS X El Capitan. xcode is updated.

What am I doing wrong?!?! Why won't this work?!?!

Upvotes: 3

Views: 704

Answers (1)

Tin Nguyen
Tin Nguyen

Reputation: 5330

I see you are having troubles installing pip. An alternative way of installing pip is through get-pip.py

https://pip.pypa.io/en/stable/installing/

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py  
python get-pip.py

Now you can use pip install

python -m pip install pip --upgrade
python -m pip install twint

Upvotes: 1

Related Questions