0

In new Ubuntu server, I run the following commands to install pip.

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

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

But python3 can not find the installed modules. Does anybody know how to install pythons modules so that they can work properly?

$ which pip3
/usr/local/bin/pip3
$ pip3 install socks
Requirement already satisfied: socks in /usr/local/lib/python3.8/dist-packages (0)
$ which python3
/usr/bin/python3
$ python3
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socks
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'socks'
user1424739
  • 11,937
  • 17
  • 63
  • 152
  • you are probably looking for `/usr/local/bin/python3`, no? – juanpa.arrivillaga Jan 22 '21 at 03:52
  • The best way to handle environment is using venv for every application. – Mohanlal Prajapati Jan 22 '21 at 03:54
  • I don't have /usr/local/bin/python3. I used the default python3 to install pip. Should pip install it in /usr/bin. I don't understand why the installation instruction of pip is something that does not work. – user1424739 Jan 22 '21 at 03:54
  • ^^^ Seconded, you should use virtual environments, and you shouldn't mess with the system python to be safe – juanpa.arrivillaga Jan 22 '21 at 03:54
  • @user1424739 try to see if this answers your question [https://stackoverflow.com/questions/42304140/python3-does-not-find-modules-installed-by-pip3](https://stackoverflow.com/questions/42304140/python3-does-not-find-modules-installed-by-pip3) – mahaveer jeevagan Jan 22 '21 at 03:58
  • 1
    since you are using python installed through package manager i suggest to install pip using `sudo apt install python3-pip python3-venv` – sahasrara62 Jan 22 '21 at 04:06
  • No. The link does not answer my question. I have no interested in debugging what is wrong. I just want to know what commands I need to run to make pip3 properly installed so that the packages can be used with python3. – user1424739 Jan 22 '21 at 04:06
  • @sahasrara62 How to uninstall the pip and modules installed in /usr/local? – user1424739 Jan 22 '21 at 04:14
  • 1
    @user1424739 on this i strongly suggest not to disturb that part now as it might cause your system failure as some application might depend on it (saying it with experience), use a virtual env for the project that would be great, otherwise, if you want to use python only in system, i suggest you to install python3 and pip3 in known location and in ubuntu bash shell provide the path to that python to execute, and run. again, strongly suggest , unless u really know how system python configured, don't touch `/usr/local/` python – sahasrara62 Jan 22 '21 at 04:18
  • @sahasrara62 It still doesn't work with `apt install python3-pip python3-venv`. $ which pip3 /usr/bin/pip3 $ pip3 install socks Requirement already satisfied: socks in /usr/local/lib/python3.8/dist-packages (0) – user1424739 Jan 22 '21 at 04:27
  • try if `python3.8` open python interpreter in the terminal, and see `socks` there, otherwise try open `python3` or `python3.7` in terminal to see which python are installed, again suggesting it is better to use a virtualenv instead of going through this all troublesome – sahasrara62 Jan 22 '21 at 04:33
  • https://stackoverflow.com/a/60349800/11138259 – sinoroc Jan 23 '21 at 10:36

1 Answers1

0

I turns out this pip3 installation command should be used.

pip3 install pysocks
user1424739
  • 11,937
  • 17
  • 63
  • 152
  • Use `path/to/pythonX.Y -m pip install pysocks` or `python3 -m pip install pysocks` instead. Guaranteed to install for the correct Python interpreter. – sinoroc Jan 23 '21 at 10:37