1

I am trying to run a Python script locally using python3. This script requires proxymanager.

Requirement already satisfied: proxymanager in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (0.0.6)

However, when I run the script, I get the following message:

  File "/Users/xxx/Folder/script.py", line 5, in <module>
    from proxymanager import ProxyManager
ModuleNotFoundError: No module named 'proxymanager'
Python 3.9.0

I believe Python is installed here:

/Library/Frameworks/Python.framework/Versions/3.9

Any help would be appreciated, still new to this. Thank you!

supra98
  • 19
  • 3
  • Are you sure that you use the same python distribution for checking the packages and invoking the script? – Mikhail Genkin Oct 16 '20 at 14:59
  • `pip --version` tells you which `python` the `pip` is attached to – Pranav Hosangadi Oct 16 '20 at 15:17
  • Does this answer your question? [Modules are installed using pip on OSX but not found when importing](https://stackoverflow.com/questions/37341614/modules-are-installed-using-pip-on-osx-but-not-found-when-importing) – Pranav Hosangadi Oct 16 '20 at 15:18
  • Have you tried `/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 /Users/xxx/Folder/script.py` ? – Philippe Oct 16 '20 at 16:18

4 Answers4

0

Try uninstalling it and reinstalling again, maybe using

pip uninstall proxymanager

Does it work? Otherwise, are you using an IDE like PyCharm?

MD98
  • 344
  • 2
  • 9
  • It does remove it, but when I reinstall with `pip3 install ProxyManager`, the script still won't run. I am using Terminal for the install. – supra98 Oct 16 '20 at 15:32
0

It can be the case that you are using pip for a different Python distribution. Here are the steps to make sure everything goes as planned.

  1. Make sure you run the distribution you need. Type which python3 into your terminal and see which Python gets run. Is it the one you expected? If not, consider using a symlink or maybe stick to the one that actually gets run.
  2. You can launch pip for the interpreter you need by using option -m:
    python3 -m pip install proxymanager
    
  3. Launch your script again and see if everything goes as planned.

Consider also using virtual environments to avoid this type of confusion in the future.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Pavel Vergeev
  • 3,060
  • 1
  • 31
  • 39
  • ```% which python3 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3``` It is the one I expected, Python3. So, I am using Terminal for all these installs, should I be using something else? – supra98 Oct 16 '20 at 15:35
  • That's correct, just use the terminal, that's all you need really. The command `python3 -m pip install proxymanager` will install your library in the correct place. – Pavel Vergeev Oct 16 '20 at 15:44
  • 1
    ```python3 -m pip install proxymanager Requirement already satisfied: proxymanager in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (0.0.6)``` and then ```python3 -m pip uninstall proxymanagger WARNING: Skipping proxymanagger as it is not installed.``` – supra98 Oct 16 '20 at 15:53
  • Oh wow, this is something weird. Unfortunately I don't know the explanation for this behavior, I can only offer a couple of workarounds. (1) Try deleting the folder for proxymanager inside `/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages` manually and installing it again (2) Try using a virtual environment, they isolate the installed libraries really well and maybe it'll fix the issue. – Pavel Vergeev Oct 16 '20 at 16:00
0

I would consider looking at virtual environments. What the problem maybe here is that your python installation is looking in the wrong place for proxymanager.

A virtual environment is a confined environment for a given project, so if you only needed certain packages for one project then you could just deal with this environment and install them to that environment. It makes developemnt and deploying projects a lot easier.

Try this, create a new folder and open a terminal window in this folder. Run the following commands. It uses the package Venv which comes with Python.

Create the environment in a folder MyProj

MyProj>> python -m venv MyEnv

Activate the environment

MyProj>> cd MyEnv/Scripts
Scripts>> ./activate

You will know it is activated as your command prompt will now have the name of the environment in front of it. Now install your package.

(MyEnv)MyProj>> pip install proxy-manager

Ensure that it is installed in your Environment.

MyProj>> cd MyEnv/Lib/site-packages
site-packages>> ls 
pip
pip-19.2.3.dist-info
pkg_resources
proxymanager    ***** HERE IT IS *****
proxy_manager-0.0.6-py3.7.egg-info
setuptools
setuptools-41.2.0.dist-info
tests
__pycache__
easy_install.py

Now try to run your script and it should use the virtual environment you have created.

WK123
  • 620
  • 7
  • 18
0

So, I did pip3 list to check what modules were currently installed.

I saw that ProxyManager was installed but it wasn't the correct module. I typed pip3 uninstall ProxyManager. Then I typed pip3 install proxy-manager. The script worked perfect after this change.

I'm unsure what was causing the error, but looks like it needed proxy-manager and not ProxyManager.

Log:

ModuleNotFoundError: No module named 'proxymanager' 

Now it works just fine. I still don't understand much of what's happening, but it looks like there's two packages with the similar name? It doesn't help that Terminals output is that ProxyManager is missing, when it was installed the entire time. The correct output should have been Proxy-Manager is missing?

Either way, thanks to everyone that has helped.

supra98
  • 19
  • 3