Error installing Tweepy for Python (Mac) - python-2.7

I'm working with Python 2.6.6 and have been trying to download tweepy, but whenever I import tweepy in the Python IDLE shell it comes back with a "No module named tweepy" error.
I've downloaded tweepy using
sudo pip install tweepy
And it goes right into /Library/Python/2.7/site-packages with no problems.
Then I cd from that path into tweepy and
python setup.py install
but this error message comes up
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'python': [Errno 2] No such file or directory
I've gone through the path and everything is correct with Python at the end.
However, when I open up a Python IDLE shell and
import tweepy
the "No module named tweepy" error comes up.
I'd really appreciate any help!

pip is using Python 2.7, as you can tell from the site-packages path, while you are apparently trying to install for use with 2.6. Leaving aside the question of why you're using 2.6, the problem is easy enough to fix - install pip with Python 2.6.
Download get-pip.py, then (assuming your python command points to version 2.6) run:
sudo python get-pip.py
Once it's installed, you should be able to run
sudo pip2.6 install tweepy
and everything should work properly.

Related

ImportError: 'No module named plotly.plotly' in LinuxMint17.3

Whenever I am trying to compile the following code to get a line graph shows some errors. But I don't know how to fix it. Here is my code :
import plotly.plotly as py
import plotly.graph_objs as go
# Create random data with numpy
import numpy as np
N = 500
random_x = np.linspace(0, 1, N)
random_y = np.random.randn(N)
# Create a trace
trace = go.Scatter(
x = random_x,
y = random_y
)
data = [trace]
py.iplot(data, filename='basic-line')
Shows the following error :
mks#mks-H81M-S /media/mks/KUTUBUDDIN1/test $ python datdaPlot.py
Traceback (most recent call last):
File "datdaPlot.py", line 1, in <module>
import plotly.plotly as py
ImportError: No module named plotly.plotly
mks#mks-H81M-S /media/mks/KUTUBUDDIN1/test $
How can this be fixed?
Added:
According to Spandan Brahmbhatt, I have installed pip by sudo pip install plotly. But still shows the following error:
You will need to install them first.
pip install plotly
pip install cufflinks
In my case I wanted to use in a Jupyter Notebook in Windows 10 but was getting the same error
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import plotly.express as px
ModuleNotFoundError: No module named 'plotly'
Considering you can also install Anaconda in Linux Mint and these came with Anaconda (in my case), if you decide to go with Anaconda you'll have at least two options to install plotly
Anaconda Prompt
Anaconda Navigator
Once installed, you'll be able to use it without any problem
1. Anaconda Prompt
Open Anaconda Prompt
Run the following command
conda install -c plotly plotly=4.8.1
2. Anaconda Navigator
Open Anaconda Navigator
Inside of it, go to Environment, select All in the dropdown and search for plotly.
Then select plotly from that list and click Apply.
I had the same problem. I accidentally was using a file in my working directory named ploylt.py. I removed that file form the directory and it works fine now.
First make sure that you have installed plotly
pip install plotly
(Test) Open an empty file, type
import plotly
and save it with a .py extension. Then run it. If this works, then your installation was ok. Move any other file named plotly (with any extension) in a different directory
It will hopefully work.
Based on ImportError: No module named plotly.plotly, I assume you have not installed plotly module.
You can install it using pip
$ pip install plotly
or
$ sudo pip install plotly
Use this:
conda install -c https://conda.anaconda.org/plotly plotly
Firstly, I'm new to plotly 2, and I am not sure I can make you understand since I'm a Chinese.
Anyway, you can try this, for me, it works:
import plotly
plotly.offline.init_notebook_mode(connected=True)
import plotly.offline as py
import plotly.plotly as py: this command will communicate with a Plotly Cloud or Plotly Enterprise. get_figure downloads a figure from plot.ly or Plotly Enterprise. You need to provide credentials to download figures: Getting Started with Plotly for Python
Refer:
Why Python line plot shows : Don't have an account? plot.ly
If you are using jupyter notebook in windows, then open the Anaconda Powershell Prompt(better to open in admin mode) and use the below command.
pip install plotly
pip install cufflinks
If you are using python from command prompt or which is set in the Environment variable then open the command prompt and use the same command mentioned above.
Both use different instance of python. So, if you use the above mentioned pip command in Anaconda PowerShell than it will install the libraries(plotly and cufflinks) in the python folder that comes with anaconda package but not in the python folder that you are using form the command prompt or which is set in the Environment variable.
I had the same problem. I found the solution by going through the directories.
pip install is installing in default python lib folder, all you have to do is copy the plotly folder from python lib to jupyter notebook lib folder. Since I am using windows the directories were as following :
c:\python34\lib\site-packages
c:\Anacoda3\Lib\site-packages
In case you searched around like I did until I found the link below, but looked here first, hopefully this will save you some frustration.
Delete the plotly.py file in your root folder. The one you created to test the get started code.
After you do that you'll be searching for a while again unless you delete the .pyc file (and get the ImportError: bad magic number in 'plotly': b'\x03\xf3\r\n').
https://github.com/plotly/plotly.py/issues/723
I was also having the same issue, but then it was due to different versions of python.
You might want to try the following command as well: (assuming you have python3 installed)
sudo pip3 install plotly
pip3 install plotly --upgrade
python3 <filename.py>
Please ensure that all the packages that are being used are installed for one python version only. As in my case all packages were installed for python3 but then I was trying to run my code with "python filename.py" and somehow that did not work.
Moreover, I also setup the credentials by following the link: https://plot.ly/settings/api. Register yourself using the link https://plot.ly/settings/api. Then create a file ~/.plotly/.credentials with your username and authentication key.
Hi I ran into something similar on my PC and here is what I advise you to do because it worked for me:
Open your Anaconda Prompt and run pip install plotly==4.1.1 cufflinks
Note that the 4.1.1 here is the version of plotly.
Installation:
Terminal:
- You can find more information about both plotly and cufflinks here.
Anaconda, Jupyter Notebook and Visual Studio Code:
- I believe I ran into this error because I did not install plotly on my PC so you can find more information on various ways of installing plotly here.
Like #Ananada, I had named my test file "plotly.py", i.e. the one containing the import plotly.graph_objects as go statement. So Python was trying to import the module from the script file I was running. Doh! Renamed it and problem solved.
To install plotly:
conda install -c plotly plotly
To check whether the installation was successful:
python3 -m pip show plotly
This shows the version of plotly installed in case of successful installation.
This worked for me!
Activate your environment again after installing the package if you are using a virtual environment.
Do source bin/activate if using bash. See https://docs.python.org/3/tutorial/venv.html.
Check your folder ... If this a temporary/test folder, maybe just like me you are wasting your whole day trying to understand why you cannot import .... .. ..
Maybe, just like happened to me - you have ANOTHER plotly.py file in your folder. Yes, that one.
Actually the module plotly is not pre-installed and we need it to be installed on our machines before using. It can be installed by using pip command :
pip install plotly
Also, we can install cufflinks. Cufflinks are smart plots.
pip install cufflinks
When you will get an error using anaconda navigator plotly install.
Go to the particular environment in Anaconda Navigator.
Then open terminal for the environment.
Install the packages.
On my Laptop, I had to use this code
!pip install pip plotly
Installing the "!" is key for my installation
All the best

No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

Have found a similar issue, however haven't found proper solution.
Here's a code:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,2,5])
plt.show()
Run, got the message:
ImportError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I run Linux Mint 18 with preinstalled python-2.7 and python-3.5 (I use python3), before that I was installing modules with a simple sudo apt-get install method and that worked great.
Before running this the code above, I've installed matplotlib in a usual way sudo apt-get install python-matplotlib. As it haven't worked out, started to look for solution.
Python location
which python3 /usr/bin/python3
Current Matplotlib installed
sudo find /usr | grep matplotlib /usr/lib/python3/dist-packages/matplotlib
My tries:
1) I've removed matplotlib with autoremove, and tried to make it sudo apt-get install python3-matplotlib instead. Didn't worked out.
2) Used: pip3 install matplotlib or sudo pip3 install matplotlib. Received errors like:
command python setup.py egg_info failed with error code 1 in /tmp/pip-build- ....
3) Then I found another solution:
sudo apt-get install virtualenv
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install matplotlib
Same outcome.
Haven't tried to use import sys sys.path.append('/usr/lib/pymodules/python2.7/')(proposed in link above), but as I am not sure what exactly this command does (quite a newbie to python and programming itself) - haven't risked.
If you are using pycharm and have matplotlib.py in your current working directory than you get this error. Just delete or rename the matplotlib.py file and it will work.
don't name any file as matplotlib.py within your working directory
In your working directory, check if there is any file matplotlib.py
Delete that file and import matplotib again. That should work.
simply install:
python -m pip install -U pip
python -m pip install -U matplotlib
I had the same problem reasons in my case were
python 3.8.2 with matplotlib that I downloaded was for 3.7. Make sure they are the same.
python 64 bits version with matplotlib 32bits. Make sure they are the same
Use python -m pip install package_which_you_need to install packages for Windows
Make sure to add to PATH the environment variables I forgot to do in my case
pip version was old use
Use python -m pip install --upgrade pip to upgrade pip to the latest for Windows
I saved the file name as matplotlib.py. Try to avoid that
Finally I typed matplotlib.pyplot as matplotlib.plyplot remember to check for typos first. The error message looks similar even though I corrected all the steps above.
ModuleNotFoundError: No module named 'matplotlib.pyplot'
ModuleNotFoundError: No module named 'matplotlib.plyplot'

Error running tweepy on QGIS: No module named tweepy

I went through all the previous questions on the subject but could not solve the problem.
I have installed tweepy through pip with no errors but got the error: "No module named tweepy" when I tried importing tweepy in QGIS. I uninstalled and reinstalled in the following directory:
C:\OSGeo4W64\apps\Python27\Scripts and still got the same error.
Than I reinstalled using "pip install tweepy". Now I can see the tweepy folders installed in both directories:
C:\OSGeo4W64\apps\Python27\Scripts and C:\Python27\Lib\site-packages.
I still get the same error.
What may the problem be?
try to pip uninstall tweepy
and then again pip install tweepy
Check if you have tweepy folder here C:\OSGeo4W64\apps\Python27\Lib\site-packages
And in Qgis Python console import tweepy
Checked in Qgis 2.18.3

invalid syntax error while installed tweepy in anaconda python 2.7

I am very new to python and anaconda. I am trying to install tweepy using pip install command
pip install -i https://pypi.anaconda.org/pypi/simple tweepy
I had referring to this command in
https://anaconda.org/pypi/tweepy
I am getting the below error:
File "<ipython-input-3-57dd52ca9b36>", line 1
pip install -i https://pypi.anaconda.org/pypi/simple tweepy
^
SyntaxError: invalid syntax
Tried a lot searching for this, but could not find one which can solve this problem.
You're supposed to run that in your command shell, not a Python REPL.

How do I get the path of a package installed with PIP, and chang that path?

I installed virtualenv with PIP.
pip install virtualenv
Everything appeared to go smoothly. When I enter
$ pip freeze
it lists
virtualenv==1.10.1
I can import it with python just fine
$python
...
>>> import virtualenv
>>>
Yet when I try to create a virtual env:
$virtualenv test
-bash: virtualenv: command not found
I assume this is because of my Path, but I am not sure how to find the path or change it. How do I fix this?
If I do
$sudo find /- virtualenv
/usr/local/share/python/virtualenv
When I do
brew info python
I get
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
Which is not where virtualenv is. This seems to happen with everything I've loaded with PIP lately. Is there a universal fix to get the directory PIP installs to line up with the directory Python thinks its installing?