Can't access Python modules - python

I can't get any python modules to install, please help me if you can.
I'm running Windows and I have python 3.5.1 (v3.5.1:37a07cee5969) [MSC v.1900 64 bit (AMD64)] on win32. Python35 is installed to C:\Python35. I also have Anaconda3 installed. I've set up PATH to include: (C:\Python35\Scripts\;C:\Anaconda3;C:\Anaconda3\Lib\site-packages\;C:\Anaconda3\Scripts), which I think encompasses everything I need for that.
Specifically, I'm trying to install Numpy, Pandas, and the Quandl module using pip install. From the command prompt, I've already done "conda install numpy", "conda install pandas", and "conda install Quandl", all of which installed and I can find them in C:\Anaconda3\Lib\site-packages\, but when I go to the command prompt and access python, and then enter "import numpy" (or pandas), it returns a Traceback error - ImportError: No module named 'numpy' ('pandas'). When I try to enter "import Quandl", it errors returning:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\Quandl\__init__.py", line 11, in <module>
from .Quandl import (
File "C:\Python35\lib\site-packages\Quandl\Quandl.py", line 11, in <module>
import pandas as pd
ImportError: No module named 'pandas'
For more information, when I attempt to do 'pip install numpy' from command prompt, it errors out on a lot of things stating "NOT AVAILABLE", and at the bottom is states:
Command "c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\BradyA\\AppData\\Local\\Temp\\pip-build-9t5yqzmk\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\BradyA\AppData\Local\Temp\pip-i6hj44h_-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\BradyA\AppData\Local\Temp\pip-build-9t5yqzmk\numpy\
Any thoughts? Thank you.

Here is a solution that worked for many:
Open cmd as admin.
Go to required pythons scripts folder: C:\Python34\Scripts
Now type pip pip install --upgrade pip(just a check)
For NumPy (you cannot do it directly)(others also):
4.1. Download all the packages you need from here :
4.2. Now type : pip install [file location of package]
4.3. This should do the trick.
Note: For more detailed explanation please look at this tutorial
Keep me posted on the progress.

Try run your command prompt as an administrator, then issuing the pip install commands.

It seems that you have conflict between the two different installations of Python.
I had similar problems in the past and deleted all Pythons, cleaned the path and reinstalled Anaconda and used Anaconda environments to work with multiple versions of Python.
Installing with conda should work with you have just Anaconda.

Related

ModuleNotFoundError: No module named 'cryptography'

these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.

No module named '_ctypes'

I'm trying to install pyautogui, but pip keeps throwing errors. How to fix it? I've tried installing libffi library. Here is some code:
python3 -m pip install pyautogui
Defaulting to user installation because normal site-packages is not writeable
Collecting pyautogui
Using cached PyAutoGUI-0.9.50.tar.gz (57 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sxm4ewnq/pyautogui/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sxm4ewnq/pyautogui/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-85ugzov6
cwd: /tmp/pip-install-sxm4ewnq/pyautogui/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
That's from python REPL
>>> sys.path
['', '/home/walenty/apps/Python-3.8.5/Modules/_ctypes', '/usr/local/lib/python38.zip', '/usr/local/lib/python3.8', '/usr/local/lib/python3.8/lib-dynload', '/home/walenty/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/site-packages']
>>> import _ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '_ctypes'
Required
Install foreign function interface headers
sudo apt install libffi-dev
Reinstall Python
Substitute desired python version
Ubuntu
sudo add-apt-repository ppa:deadsnakes/ppa -y && sudo apt reinstall python3.9-distutils
MacOS
Use brew install python3.9 or port install python3.9 (I recommend port)
Windows
Use Microsoft Store
Specify project python version
Poetry
poetry env use 3.9
Virtual envs
virtualenv -p python3.9 myproject
etc...
okay, I've got it. This is the answer Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing
I cloned python3.10 from git and installed it from scratch.
As other answers say, you need to install libffi-dev. If you're using pyenv/virtualenv, also reinstall the base python version:
Install libffi
sudo apt-get install libffi-dev
Load the new libffi.so, as suggested here
sudo ldconfig
Reinstall the python version available to pyenv
pyenv install 3.9.12
Finally, create the fresh virtualenv
pyenv virtualenv 3.9.12 new_environment

python install scrapy - failed with error code 1

I tried to install scrapy by "pip install scrapy", and I got:
c:\python36\python.exe -u -c "import setuptools,
tokenize;__file__='C:\\Users\\tzvia\\AppData\\Local\\Temp\\pip-install-
07h63108\\Twisted\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\tzvia\AppData\Local\Temp\pip-record-hy8qkma1\install-record.txt
--single-version-externally-managed --compile" failed with error code 1
in C:\Users\tzvia\AppData\Local\Temp\pip-install-07h63108\Twisted\
I tried "conda install -c conda-forge scrapy" and it seems like the scrapy already installed:
C:\Users\tzvia>conda install -c conda-forge scrapy
Solving environment: done
# All requested packages already installed.
so I tried using scrapy and go an error:
C:\Users\tzvia>scrapy
Traceback (most recent call last):
File "C:\Users\tzvia\Anaconda3\Scripts\scrapy-script.py", line 6, in
<module>
from scrapy.cmdline import execute
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\__init__.py", line
34, in <module>
from scrapy.spiders import Spider
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\spiders\__init__.py", line 10, in <module>
from scrapy.http import Request
File "C:\Users\tzvia\Anaconda3\lib\site-packages\scrapy\http\__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "C:\Users\tzvia\Anaconda3\lib\site-
packages\scrapy\http\request\form.py", line 11, in <module>
import lxml.html
File "C:\Users\tzvia\Anaconda3\lib\site-packages\lxml\html\__init__.py",
line 54, in <module>
from .. import etree
ImportError: DLL load failed: The specified module could not be found.
I tried to install lxml, and got again "failed with error code 1".
can someone help me?
I use python 3.6.1 and windows 10
I think it is because your Twisted install failed.
Download the Twisted .whl file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted .
Then run
pip install <Twisted-your-version.whl>
Installing lxml on Windows can be a bit of pain.
You might want to check out the info they have on their site here. They suggest that if building from source fails you might want to use the unofficial pre-built binaries by downloading from here and then running
python -m pip install .\lxml-4.2.5-cp37-cp37m-win32.whl
Make sure to download the version that you need. If you're using python 3.6 you should get the cp36 one.
Forget about pip install! The issue with 'scrapy' is all over the Web. Download 'Scrapy-2.5.0.tar.gz' (or whatever version is current) from https://pypi.org/project/Scrapy/, exract it to a temp folder and run < python setup.py install >

Installing numpy, cython, cpython for Python 2.7.12

I have been trying to install numpy for Python 2.7.12 on a ubuntu 16.04 machine, but am not sure I am doing the right thing.
I issued the command
python setup.py install
and received the following error message:
ImportError: No module named Cython.Compiler.Main
So I have also been trying to install the cython package and received another error message:
/Cython-0.28.1/Cython/Plex/Scanners.c:19:20: fatal error: Python.h: No such file or directory
I thought this problem required me to install cpython. Trying to install this resulted in the following error message:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import sys, os, importlib.machinery, re, optparse
ImportError: No module named machinery
I am somewhat stumped about how to continue. Am I on the right path? Is there a different way I could try (the computer in question cannot connect to the internet)?
You can check if pip is install thanks to the command which pip,
in my case :
$ which pip
/home/usr1/anaconda3/bin/pip
If pip is not install install it : instruction here
then you should be able to use it such as :
pip install numpy
an alternative is to use : conda install
In the terminal use:
pip install numpy
If you get any error like 'permission denied', try:
sudo pip install numpy

Django Taggit Module Installation Error: No module named setup tools

The title basically explains it all.
I am running Windows 8 (windows 7 was previously installed... If it helps with answering) and am using Python 2.7.
Upon using the code:
python setup.py install
I am getting this error:
C:\Users\Nicholas\Desktop\taggit>python setup.py install
Traceback (most recent call last):
File "setup.py", line 52, in
from setuptools import setup
ImportError: No module named setuptools
Any help?
Thanks in advance
Nicholas
You need to install setuptools, which allows packages to be configured for your Python installation. It is not included with the default Python installer.
From this link you can download Windows installers for many Python packages (I have linked it directly to setuptools). Make sure you download the version that matches your Python installation.
in Python 3:
pip3 install setuptools
And in Python 2.x:
pip install setuptools

Categories