I have cloned the git repository of flask(https://github.com/mitsuhiko/flask). I run Python 3.4.1 on both my windows and ubuntu machines. To install flask(on windows), I just change directory to flask repository on my machine and run python setup.py build install . Flask successfully installs and runs. When I try repeating the same steps on ubuntu, it simply throws an error saying
Traceback (most recent call last):
File "flask_example.py", line 1, in <module>
from flask import Flask
ImportError: No module named 'flask'
I tried installing flask through pip, pip install flask and by using "virtualenv" with easy_install as well. I still get the same error. Can anyone tell me what the issue could be?
In all Ubuntu versions so far, pip command defaults to one that installs packages for the latest Python 2 version installed, i.e. most probably Python 2.7; this is the python that will start with python command.
Python 3 instead is runnable as python3 or python3.4; there is a corresponding version of pip, such as pip3 (for the default Python 3 version), or pip3.4 for the pip that specifically installs the packages for the Python 3.4 versions.
Most notably, pip does not know anything about what are the possible aliases in the command shell (bash, zsh), and thus is completely oblivious to those.
Related
I'm got a working respiratory of codes working on Azure in a function app (version 3). However, I can't get it running locally. The reason for this is (i think) because the Azure Core Tools doesn't link to my Conda environment.
When I run 'func start' the output first generates the following
(myenv) C:\mypath\__app__>func start
Found Python version 3.8.0 (py).
This is odd because in myenv (conda environment) I have installed python 3.8.13, which is the version I need. The result of this difference in versions leads to multiple modules not being found.
Error message:
Exception: ModuleNotFoundError: No module named 'azure.identity'.
I installed Core Tools v3
After reproducing from our end we could able to make this work after installing the azure.identity in your environment.
pip install azure-identity
Also, make sure you install the packages in requirements.txt file by running the command
pip install -r requirements.txt
I am using Ubuntu Server 18.04 LTS(HVM)-free tier to run my python script. I connect with the Key to the server with Putty. I manage my files loaded onto the the server using FileZilla. After I install python on the server with sudo apt install python3 I install Selenium using pip install -U selenium. The process is a success. I then load my python script through FileZilla and then try to run the python script. Like most that have asked I get the error:
Traceback (most recent call last):
File "BinaryAutomation.py", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Now please understand this. I have tried to install selenium manually by installing and unachieving the file found here, which basically downloads the setup to be loaded using python setup.py install. I do not have permission to paste anything under tmp\usr\bin I have tried that. How do i get around this problem?
You probably have other versions of python/pip installed. Install packages using pythonx -m pip install ... with pythonx your python version (python3 I presume) to avoid installing packages for a version of python that you're not using to run your scripts.
For more details check: Why you should use python -m pip - Snarky
Ubuntu generally follows PEP 394, which says that the command python should be Python 2. So, use python3 instead of python. That extends to PIP too, so I would say to use pip3 instead of pip, but that method is becoming outmoded; use python3 -m pip instead.
This is assuming you haven't changed the python and pip commands.
I installed a Python module using pip. When I tried to import it, I got this error:
Traceback (most recent call last):
File "Untitled.py", line 1, in <module>
import watson_developer_cloud
ModuleNotFoundError: No module named 'watson_developer_cloud'
What can I do to fix this?
I am using macOS Mojave 10.14.2 (beta), pip 10.0.1 (I also tried to upgrade it to 18.1, but after the install the version stayed the same).
You probably installed it with sudo, so it's not accessible when you run the script without sudo. Anyhow, it's really messy to install modules directly. And it's dangerous to install modules to systems python.
Install a brew version of python and pip. then create a virtualenv and install your packages in it. It's much safer and portable.
Read this answer No module named 'pafy'
Please don't run the script as sudo to make it work, especially if you are not the one who wrote it. Use a virtualenv instead.
I have been trying to install various modules that I need to have to run this script:
https://github.com/austingandy/slack-evernote/blob/master/slackwriter.py
I am working off a Mac, and my python --version is:
Python 3.4.3 :: Anaconda 2.3.0 (x86_64)
And I have for python -m pip --version:
pip 8.0.2 from /Users/dhruv/anaconda/lib/python3.4/site-packages (python 3.4)
However, for example when I run pip install evernote I get errors like:
Collecting evernote
Using cached evernote-1.25.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/cj/5gs43w4n2tz313rrnz9_htf00000gn/T/pip-build-0y7hm202/evernote/setup.py", line 6
exec x
^
SyntaxError: Missing parentheses in call to 'exec'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/cj/5gs43w4n2tz313rrnz9_htf00000gn/T/pip-build-0y7hm202/evernote
I have a feeling that these errors are because the setup.py code that pip has is in python 2.7 format, and my environment is 3.4, but how can I overall install all the packages I need to run this script? Would I change to python 2.7, install in that environment, and then repackage the setup of evernote into python 3.4 format? If so, how?
AFAIK, Evernote SDK for Python 3 is not yet supported.
https://github.com/evernote/evernote-sdk-python3
This is a test SDK! The official Evernote SDK for Python doesn't
support Python 3 yet; this repository is an experiment as we try to
migrate.
You can try installing manually from the link above or downgrade to python2 in your virtual env.
While it is possible to migrate a script from Python 2 to Python 3, doing it right isn't trivial. You could try using 2to3 but I suspect it won't quite do the job.
The easiest is to just use virtualenv with Python 2. I'm not sure how it is on Mac but on Linux you can just have both versions of Python installed in parallel and you can pick the one you need in your virtualenv as e.g.
virtualenv -p python2 venv
where python2 is your Python 2 binary and venev the directory you want tot install the virtualenv into.
Where you might run into trouble is the activate scripts which are only available for specific shells. However, you could probably adapt one if none works out of the box.
Ubuntu 15.10
Python 3.4.3+
Django 1.8.7
When I try to import django in the python3 interpreter, it says ImportError: No module named 'django'. I know Django 1.8.7 installed though, 'cause I can get the version # by doing django-admin --version in the terminal commandline.
When I tried python3 manage.py runserver in a Django project directory, I get this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django'
So again (as expected), it's not in a path where Python can find it.
I looked in /usr/local/lib/python3.4/dist-packages but it's an empty directory.
I did a whereis django & whereis Django and that simply gives me a line with django: or Django: respectively and no list of paths.
I tried Googling how to find path to Django, but that didn't turn up anything useful.
I found & checked the code of the django-admin file itself, but it doesn't have anything indicating where Django installed to. Oddly, the python file imports the django module and it works, even though the interpreter & Django project files can't see the django module. So it's on the python path but it also isn't?!? I don't know, and I can't find it.
I never had a problem like this with a previous Ubuntu (or any other OS). Has anyone got a clue how I can find where Django installed? Actually, I can't find any of the modules I installed via pip3. I've been trying to figure this out for over an hour now, and I'm very confused & frustrated.
Normally pip 3 install on python3 dist-packages
You can always use pip with:
python3 -m pip install package
to check if you are experiencing troubles with another python3 installation
ls /usr/local/lib | grep python
But the easy way to not experiment this headache is by using virtual environments
I think you have installed django outside virtual environment.
download virtual environment by
pip install virtualenv
virtualenv your_env
Activate virtual environment.
source your_env/bin/activate
Then,
Install django in your virtual environment.