0

i'm currently into learning a bit of python and i want to import the paperclip third party module into my python file.

Yes, i already installed the pyperclip module with pip install pyperclip.

if i create a file on my desktop, i get an error which says Traceback (most recent call last): File "test.py", line 1, in <module> import pyperclip ImportError: No module named pyperclip

However if i put the test.py in my python folder, it runs.

The question now is, is there a way to make all my installed modules available on a global scope ? I just want to have my file e.g. on my Desktop and run it without having import issues.

Thank you.

Greetings

Edit: I'm working on a Mac, maybe this leads to the problem

Tim.G.
  • 299
  • 4
  • 16
  • 1
    ... are you launching the file using `python3.5`? If you install the module for python3.5 and then use python2 or python3.4 to run the code obviously the interpreter wont find the module... – Bakuriu Jul 28 '16 at 08:56
  • 1
    To be clear: if you have properly installed the module using `pip` and you are properly launching the file with the right interpreter the module **will** be available independently of your current working directory. The fact that you get an `ImportError` means you either messed up the installation or you are using the wrong interpreter to run the code. – Bakuriu Jul 28 '16 at 08:59
  • `$ pip install pyperclip Requirement already satisfied (use --upgrade to upgrade): pyperclip in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages` `$ python test.py Traceback (most recent call last): File "test.py", line 1, in import pyperclip ImportError: No module named paperclip` `$ python3.5 test.py File "test.py", line 3 print pyperclip.paste() ^ SyntaxError: invalid syntax` (Also changed the code above ) – Tim.G. Jul 28 '16 at 09:13
  • Reading [here](https://github.com/asweigart/pyperclip) it looks like that *On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.*. maybe you don't have those installed? Try to install `pbcopy` and `pbpaste` (these are *not* python modules, but Macs programs). – Bakuriu Jul 28 '16 at 09:17
  • both pbcopy and pbpaste are installed. – Tim.G. Jul 28 '16 at 09:21
  • Also, i uninstalled pyperclip and reinstalled it, still same problem... – Tim.G. Jul 28 '16 at 09:24
  • 1
    That "SyntaxError: invalid syntax" error you're getting is because `test.py` uses Python 2 style `print` statements, which were removed from Python 3. Also, double-check your spelling --- both "pyperclip" and "p**a**perclip" have appeared in your question and in the comment I'm replying to. – Kevin J. Chase Jul 28 '16 at 10:04

2 Answers2

1

Found the problem.

The pip installautomatically used pip3.5 install
whereas python test.pydidn't use python3.5 test.py

Thank you @Bakurìu

Is there a way i can define python3.5as python?

Tim.G.
  • 299
  • 4
  • 16
  • 1
    See [this question](http://stackoverflow.com/questions/18425379/how-to-set-pythons-default-version-to-3-3-on-os-x). – Bakuriu Jul 28 '16 at 09:58
0

You can do this :

pip3.5 install paperclip

pyperclip is install but not paperclip

Arnaud Wurmel
  • 480
  • 3
  • 15