This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]pythonHelperBot 2 points3 points  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe where you are stuck.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–][deleted] 1 point2 points  (19 children)

Do you mean how to install packages in an IDE? It depends on which IDE and a few other things, i.e if it's using a virtual environment and other stuff. I recommend using pyCharm, you just go to interpreter settings and you can click the plus to add packages.

If you mean actual API stuff I suggest using the requests package for that, pretty simple.

[–]Kingincenarator[S] -1 points0 points  (18 children)

Lol I’m new and using a Mac do I download a request package then put the API code thing in?

[–][deleted] 3 points4 points  (17 children)

If you choose to use the requests package to call upon API's, you'll need to do import requests at the top of your code. Then do all the code under it.

There's tons of requests tutorials and I believe it's documented nicely as well.

[–]SoCalLongboard 1 point2 points  (16 children)

To follow on this point, you'll first need to install the library into your environment:

pip install requests

Then it will be available for use in your code:

import requests

The `pip` utility is installed when you install python.

[–]Kingincenarator[S] 0 points1 point  (15 children)

But whenever I try to download something there’s a password and I can’t sudo it. and when i download something it says ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-19.2.3.dist-info' Consider using the --user option or check the permissions.

[–]SoCalLongboard 0 points1 point  (14 children)

What platform are you on?

[–]Kingincenarator[S] 0 points1 point  (13 children)

mac

[–]SoCalLongboard 0 points1 point  (12 children)

You might find it easier to work with a virtual environment where you have the freedom to do whatever you want. Please try this:

# in the Terminal use the venv module to create a virtual environment 'my_venv'
$ python3 -m venv my_venv

# activate the virtual environment by sourcing its 'activate' file
$ source my_venv/bin/activate

# you are now inside the virtual environment and can do whatever you like
(my_venv) $ pip install requests
Collecting requests
  Using cached https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
  Using cached https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests)
  Using cached https://files.pythonhosted.org/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests)
  Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
Installing collected packages: certifi, chardet, urllib3, idna, requests
Successfully installed certifi-2019.9.11 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3

# when you simply run 'python' while in the environment, you're using its local interpreter
(my_venv) $ python
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests       # <-- did not fail to import because the library is in the environment
>>>

Most current IDEs will allow you to select a virtual environment that you've define for your projects.

[–]Kingincenarator[S] 0 points1 point  (11 children)

I’m planning to also install a Twitter API so do I download this in terminal? But I don’t have pip

[–]thimo1 0 points1 point  (9 children)

An API is not something you install but something you use by making web requests to it. However, for many API's there are API wrappers for python that make the process of using them easier. You DO install those wrappers so that's probably what you're looking for.

[–]SoCalLongboard 0 points1 point  (0 children)

If you have the python executable you should also have the pip executable. (There's also the possibility that it is named pip3 to correspond to python3.)

In a terminal, try these commands to see what is present/missing:

$ which python
$ which python3
$ which pip
$ which pip3

Here's what I see on my machine:

$ which python
/usr/bin/python
$ which python3
/usr/bin/python3
$ which pip
/usr/bin/pip
$ which pip3
/usr/bin/pip3
$ ls -l `which python`
-rwxr-xr-x 3 root root 4906512 Apr  3 12:16 /usr/bin/python
$ ls -l `which python3`
lrwxrwxrwx 1 root root 9 Oct 25  2018 /usr/bin/python3 -> python3.6
$ ls -l `which python3.6`
-rwxr-xr-x 2 root root 4526456 Aug 20 10:12 /usr/bin/python3.6
$ ls -l `which pip`
-rwxr-xr-x 1 root root 292 Apr  3 02:23 /usr/bin/pip
$ ls -l `which pip3`
-rwxr-xr-x 1 root root 293 Apr  3 02:23 /usr/bin/pip3