user8642594
user8642594

Reputation: 58

Pip packages not importing

So I am unable to use the package PyMySQL from pip. I've tried installing it with pip, pip3, and easy install. I've tried running the file in python2 and python3. I've tried using python -m pip install ...

I'm on mac. My ~/.bash_profile has the following

export PATH="/usr/local/sbin:$PATH"
export PATH="/Users/taylorcochran/anaconda2/bin:$PATH"
export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH="/usr/local/cellar/openvpn:$Path"
export PATH="/Users/taylorcochran/anaconda3/bin:$PATH"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages:$PATH"

I've looked at similar problem across StackOverflow but none of the suggested solutions produce any results.

Additionally, when I try to add # PATH="/usr/local/lib" to my path it breaks the built in commands like ls and cd

Edit:

I'm running the script using python3 Test.py which simply contains the line import PyMySQL Which outputs: ModuleNotFoundError: No module named 'PyMySQL'

Tried: pip3 install --install-option="--prefix=/Library/Frameworks/Python.framewor k/Versions/3.6" PyMySQL

Outputs: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options. cmdoptions.check_install_build_global(options) Requirement already satisfied: PyMySQL in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

And still doesn't let my import the module

Upvotes: 1

Views: 625

Answers (1)

Mateusz Kleinert
Mateusz Kleinert

Reputation: 1376

You have Python 3.6 in the PYTHONPATH so you should go with pip3. Try to use the following command:

pip install --install-option="--prefix=$PREFIX_PATH" package_name

where $PREFIX_PATH in your case should be /Library/Frameworks/Python.framework/Versions/3.6

When you use Python located in /Library/Frameworks/Python.framework/Versions/3.6/bin the module library should be available.

Upvotes: 1

Related Questions